I am running an Apache 2.4.48 server with mod_cgid
and mod_fcgid
. I have a number of CGI scripts under /cgi-bin/
and have been refactoring some of them to use FastCGI. During this refactoring I need to figure out a way to support running both types of scripts out of the same directory while retaining their existing names, so the usual methods of creating a new path (e.g. /fcgi-bin/
) or renaming them (e.g. to .fcgi
) are not suitable for my needs.
My current configuration for the old-style CGI is something like this:
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory /var/www/cgi-bin>
AllowOverride All
Options None
Require all granted
</Directory>
And I have been manually setting the FastCGI handler for the updated scripts in a .htaccess
file with a directive like this:
<Files "updated_fcgi_script.pl">
SetHandler fcgid-script
</Files>
But this is quite repetitive and cumbersome. I was hoping to make it easier on myself by creating a new path on the filesystem where the updated FastCGI scripts could live (like /var/www/fcgi-bin/
), alias it to /cgi-bin/
, and then set the handler in a <Directory>
directive, with Apache serving the script from whichever directory it finds it in. Unfortunately, this doesn't seem to work; Apache accepts the configuration as valid but returns an "Access denied" for requests to both the old and new CGI scripts without any useful information in the logs.
Is there a way to achieve what I want, or is it not supported? I am not an Apache wizard, so I may have been googling the wrong things. Thanks!