This is undoubtedly the number one question people ask about Apache. The answer is to persuade Apache to execute scripts in other locations, such as in directories where normal documents may also live, you must tell it how to recognize them - and also that it's okay to execute them. For this, you need to use the AddHandler directive.
You probably have a Virtual Host directive where you're trying to accomplish this. In that specific section of your httpd.conf configuration file, add or uncomment the following line:
AddHandler cgi-script .cgi |
Note: You can also add a .pl extension to the end of this line if you want to use .pl extensions as well.
If mod_perl is installed make sure the following is not commented out:
<IfModule mod_perl.c>
Alias /perl/ /home/httpd/perl/
<Location /perl>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCGI
</Location>
</IfModule> |
The server will then recognize that all files in that location (and its logical descendants) that end in ".cgi" or ".pl" are script files, not documents.
So if you put this in a VirtualHost directive (assuming this was where you wanted to be able to run the CGI script) you'd be hot on the trail of a solution. Just make sure that the directory location is also covered by an Options declaration that includes the ExecCGI option.
There are also permissions issues associated with scripts and SWS. For a script to run with SWS the permissions on the script must be 0755 as well as the entire path to the file. You must also make sure that the owner of the directory and the owner of the file are the same.
One addendum to all of this is that if you're running SWS 3.0 there is a small bug in the httpd.conf file. This bug affects the servers ability to glob the path for public_html directories.
Here's the fix:
Find this line:
<Directory /*/public_html>
and change it to this:
<Directory /home/*/public_html>