0

Is there a method for declaring name based virtual hosts, but sharing the same directory declarations? So for example, the Directory section in both of these Vhosts is the same, so is there a method to only declare it once, and have it used by both Vhosts? Same for the Error log section. Is there a method for declaring the error log only once? (Possibly inside the Directory?)

<VirtualHost *:80>
        ServerName email.123456.com
        DocumentRoot /var/www/mail
        <Directory /var/www/mail>
                Options FollowSymLinks
                DirectoryIndex index.php
                AllowOverride All
                Order Allow,Deny
                Allow from All
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/mail/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/mail/access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName email.123456.com
        DocumentRoot /var/www/mail
        <Directory /var/www/mail>
                Options FollowSymLinks
                DirectoryIndex index.php
                AllowOverride All
                Order Allow,Deny
                Allow from All
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/mail/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/mail/access.log combined

        SSLEngine on

        SSLCertificateFile    /var/certs/123456/123456.com.crt
        SSLCertificateKeyFile /var/certs/123456/123456.key
        SSLCertificateChainFile /var/certs/123456/sf_bundle.crt

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        BrowserMatch "MSIE [2-6]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
        BrowserMatch MSIE [17-9] ssl-unclean-shutdown
</VirtualHost>
</IfModule>

1 Answer 1

4

If it were me, I'd store the shared configurations in "fragment" .conf files and use the Include directive in each VirtualHost or other place that shares the configurations within those fragments. i.e.

Include conf-fragments/error-log.conf
Include conf-fragments/Directory-mail.conf
1
  • I was wanting to keep them in the same file, but I can see some advantages (in reducing redundancy mainly), so I will give this a try. Thanks! Feb 22, 2013 at 19:09

You must log in to answer this question.

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