0

Currently My /etc/apache2/sites-enabled/000-default.conf looks like this:

DocumentRoot /var/www/htm
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
Options +ExecCGI
AddHandler cgi-script .cgi .pl
Options FollowSymLinks
Require all granted
</Directory>

I have multiple Domains that I want to access Port 80 on my Nas. On my Qnap Each Domain has its own folder titled “domain. com” with “.htaccess”, numerous “.html” containing <!—#exec cgi, <!--#include virtual, and each contain its own “cgi-bin" directory.

Could someone show me what my “.000-default.conf” should look like to accomplish my goals? Thanks!

1 Answer 1

0

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.

2
  • I cannot thank you enough for your great examples.
    – cal
    Mar 8, 2021 at 7:12
  • Marking the answer as correct (and maybe an upvote) is enough 😉
    – user1091774
    Mar 8, 2021 at 7:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .