1

With the Apache/mod_rewrite config below i get a 403 forbidden error for any CGI scripts on the root /var/www/ I don't get any error for static files.

Scripts out of root dir i.e. /var/www/random/script.cgi work normally without errors.

With RewritedEngine turned OFF CGI scripts work normally even in the root /var/www/

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
            Options FollowSymLinks
            Options SymLinksIfOwnerMatch
            AllowOverride All

            <IfModule mod_rewrite.c>
            RewriteEngine on
            </IfModule>
</Directory>
<Directory /var/www/>
    Options +ExecCGI


    Options SymLinksIfOwnerMatch
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all

            AddHandler cgi-script .cgi 

            DirectoryIndex index.cgi

</Directory>

<Files "index.cgi">
    SetHandler perl-script
    PerlHandler ModPerl::PerlRunPrefork
    Options ExecCGI
    PerlSendHeader On
    allow from all
</files>  
0

Try copying a script that is working to the root and see if it works in case it's something that doesn't have to do with the conf. Use the -p flag of cp to preserve things like execute permission. For example:

cp -p /var/www/random/script.cgi /var/www/script.cgi

  • I just tried it again as you suggested, but with a simple hello world and it worked. My actual production scripts have additional config on Apache, please see original question again with the updated config for index.cgi. – user3518089 Jun 18 '15 at 0:54
  • The error is 403 but in Apache log it says Options FollowSymLinks OR SymLinksIfOwnerMatch is OFF, i tried adding both options to <Files *> but did not work. – user3518089 Jun 18 '15 at 1:07
  • Try to match up your Apache config and file permissions between the script that's not working and the script that is working as much as possible and then see what change it is that actually causes it to break. Alternately, is one of the CGI scripts that's not working in the root actually a symbolic link to a script that resides elsewhere? – sa289 Jun 18 '15 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.