Rather than put everything in one config file, consider having each of your domains in their own .conf
file. This will allow you specify more than just which CGI-bin is used.
For example:
Site |
Config File |
example.com |
/etc/apache2/sites-available/000-example-com.conf |
secondary.com |
/etc/apache2/sites-available/001-secondary-com.conf |
tertiary.com |
/etc/apache2/sites-available/002-tertiary-com.conf |
default.com |
/etc/apache2/sites-available/999-default-com.conf |
You can enable (or disable) each of the sites with a2ensite
, like:
sudo a2ensite 002-tertiary-com.conf`
This keeps everything separated and "clean". The 999-default
is a "catch all" for Apache to use if web traffic goes to the server for a domain that is not explicitly defined. You can use a ServerAlias
line in the .conf
file to achieve this.
With this sort of setup, each of your .conf
files might look something like this:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/example/public
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ServerName example.com
ServerAlias example.com *.example.com
DirectoryIndex index.php index.html
ErrorLog ${APACHE_LOG_DIR}/example-error.log
CustomLog ${APACHE_LOG_DIR}/example-access.log combined
</VirtualHost>
<Directory /var/www/example.com/public>
Options FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
<Directory "/usr/lib/cgi-bin">
Options +ExecCGI
AddHandler cgi-script .cgi .pl
Options FollowSymLinks
Require all granted
</Directory>
Note: Be sure to replace the values for the site as you need, including the references to the different cgi-bin
locations.
This should give you the specificity (and flexibility) you need to have multiple domains use different versions of software.