I have a VirtualHost
that I am using to serve requests to files in /var/www/project/src
.
I also have a Perl script (CGI binary) that is in /var/www/project/src/cgi-bin/index.pl
.
Here's the part of the directive relevant to my question:
<VirtualHost example.com:443>
...
DocumentRoot "/var/www/project/src"
<Directory "/var/www/project/src">
Require all granted
Options +MultiViews +ExecCGI
AddHandler cgi-script .pl
DirectoryIndex /cgi-bin/index.pl
</Directory>
</VirtualHost>
The server starts, but access to the host fails as I get a 403 error.
The Apache logs indicate that the web server cannot find {document-root}/cgi-bin/index.pl
:
[Thu Nov 09 11:37:03.578316 2017] [autoindex:error]
[pid 122783] [client example-client.com:57203] AH01276:
Cannot serve directory /var/www/project/src/: No matching
DirectoryIndex (/cgi-bin/index.pl) found, and server-
generated directory index forbidden by Options directive
This directory and index.pl
file are in the right location, are owned by the apache
user, and have permissions which allow others to read the contents of directories and execute the index.pl
CGI-bin.
Moreover, if I change paths in DocumentRoot
and Directory
variables, the following configuration works:
<VirtualHost example.com:443>
...
DocumentRoot "/"
<Directory "/">
Require all granted
Options +MultiViews +ExecCGI
AddHandler cgi-script .pl
DirectoryIndex /var/www/project/src/cgi-bin/index.pl
</Directory>
</VirtualHost>
Apache starts up, and my access to the host in turn loads /cgi-bin/index.pl
, which is rendered correctly.
Question: What would cause the first set of directives to fail, where the second set works?
More specifically: What is preventing the first set of directives from finding /cgi-bin/index.pl
in the specified document root, while the second set correctly finds the fully-qualified path /var/www/project/src/cgi-bin/index.pl
?
Note: The items in ...
do not seem relevant to the issue — whether I remove them, alter them, or leave them, the error and log messages are the same in any case — so I am leaving them out for brevity.