Kyle Burton on Wed, 25 Aug 1999 17:34:24 -0400 (EDT)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [Plug] Simple CGI question (featuring RH6.0 and Apache 1.3)


By default, you have to put cgi programs in the /cgi-bin/ directory for
apache.  If you have it configured for extensions, then you need to make
sure the name ends in .cgi.

Can you run the CGI from the command line?

  ./hello.cgi

What are the permissions on the CGI?

  ls -l hello.cgi
  -rwxr-xr-x   1 nobody   nobody        319 Jun 25 12:26 hello.cgi

it it executable by other?

these are the most common problems with CGI programs.  If all these
conditions are met, and you can run it from the command line, then
make sure it's returning a valid http header.

try this as a hello world cgi (if you have perl installed):
################################################################################
#!/usr/bin/perl -w
use strict;
use CGI;
my $q = new CGI;
print $q->header,$q->start_html(),$q->h1('hello, world'),$q->end_html();
exit 0;
################################################################################

Run it like this:
  ./hello.cgi < /dev/null
it should produce this output (when run from the cmdline):
################################################################################
stty: : Invalid argument
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Untitled Document</TITLE>
</HEAD><BODY><H1>hello, world</H1></BODY></HTML>
################################################################################

make sure the first line in the script points to your copy of perl...

k

------------------------------------------------------------------------------
To be wise, the only thing you really need to know is when to say "I don't
know." 
    -- fortune file
mortis@voicenet.com                            http://www.voicenet.com/~mortis
------------------------------------------------------------------------------

On Wed, 25 Aug 1999, Tracy Nelson wrote:

> I've just started playing with Apache, and I can't seem to get CGI scripts
> to work.  I have installed a simple one (the canonical "Hello, world!"
> example from cgi101.com) in the http root directory (/home/httpd/htm).  I
> can access the script just fine, but it doesn't execute -- I just get the
> text from the script.  I can run it from the command line, and I can link to
> it from a web page, but it never executes.  I looked through the httpd.conf
> script, but I didn't see anything obvious there (like
> "PutCGIScriptsHere=..." ;).  I've read through the on-line docs that came
> with Apache and I didn't see anything there either.
> 
> Is there a good beginner's CGI book or web site anywhere?  I'm going through
> CGI 101 on the cgi101.com web site, but all they say in this case is "ask
> your webmaster".
> 
> Thanks!
> -- Tracy Nelson
> 
> 
> _______________________________________________
> Plug maillist  -  Plug@lists.nothinbut.net
> http://lists.nothinbut.net/mail/listinfo/plug
> 


_______________________________________________
Plug maillist  -  Plug@lists.nothinbut.net
http://lists.nothinbut.net/mail/listinfo/plug