httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boyle Owen" <Owen.Bo...@swx.com>
Subject RE: CGI & Apache
Date Wed, 17 Jul 2002 13:15:30 GMT
>From: Barrie Robinson [mailto:barrie.robinson@emotus.com]
>
>I think I've got it wrong, what's actually happening is it's 
>accessing a cgi
>script within the directory. I can work around this by 
>enabling cgi access
>outside the cgi bin. However when I do this I get a 
>permissions error such
>as:
>
>Forbidden
>You don't have permission to access /cgi-bin/test.cgi on this server.
>...which I got when I ran the test cgi via the same virtual host.
>
>I'm guessing is something to do with the user and group I'm 
>running httpd
>as?

More likely to be that the server is not allowed to access the directory by configuration.
How it is supposed to work is that you define a directory for your CGIs using "ScriptAlias",
e.g.

Scriptalias  /cgi-bin  /home/website/cgi-bin

This means that a request like http://your-server/cgi-bin/prog.pl will cause apache to go
to /home/website/cgi-bin/prog.pl and try to execute it. For it to succeed, several things
ahve to be right:

(1) Apache has to be configured to be allowed into this directory. This is quite separate
from unix file permissions - it is simply that you must not have a "Deny" directive applying
to that directory. This can happen if you do:

# Block access the whole filesystem...
<Directory />
 Deny from all
</Directory>

# ... then allow access to HTML area
<Directory /home/website/html>
 Allow from all
</Directory>

If you have this common scheme set up, you must either put CGI inside your docroot (/home/website/html)
OR do:

# ... also allow access to CGI
<Directory /home/website/cgi-bin>
 Allow from all
</Directory>

(2) Apache user has to be able to read and execute the program: the execute bit has to be
set and the read permissions have to allow apache to read. This is usually OK if you have
mod 755 (typical). If you have been doing something paranoid or have a funny apache user,
you might check this.

(3) The program has to work - if it fails to execute because of a syntax error, you will get
"Internal Server Error". This is usually good news since it means apache is OK it is just
your program that is broken :-)

(4) The program has to output a valid CGI header before anything else, i.e.

print "Content-type; text/html\n\n";

should appear before any other output.

Check out the CGI tutorial in the apache docs for more details.

Rgds,
Owen Boyle.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message