1

I'm using Apache on CentOS and am trying to run a Perl CGI script as directory index so it will run automatically as a subdomain. I added DirectoryIndex script.cgi and added a Directory stanza noting the path /var/www/folder enabling the script to run.

The only way the script would run is if I also add a File *.cgi stanza within the directory stanza (or even outside of it) and move the relevant section to it:

    Options +ExecCGI and SetHandler perl-script

I'm still learning Apache, and wondering why just referencing the folder wasn't enough. Why do I also have to add a File stanza and reference *.cgi? The CGI script would have been the only file in the folder.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
mike
  • 11
  • 1

1 Answers1

0

Since you want to execute a cgi-script, apache2 needn't to know about perl. So I'd remove the SetHandler directive.

To debug it, look at your /var/log/apache2/error.log or similar. Your directory has to be accessible by apache. The script you like to execute need to have the execution flag set.

Example config:

    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    <Directory "/var/www/cgi-bin/">
            AllowOverride None
            Options +ExecCGI -MultiViews
            Order allow,deny
            Allow from all
    </Directory>