Better way to write Apache site-configuration?

Posted by user195697 on Server Fault See other posts from Server Fault or by user195697
Published on 2013-10-21T08:31:17Z Indexed on 2013/10/21 9:58 UTC
Read the original article Hit count: 136

Filed under:
|

I have a question regarding the config files in /etc/apache/sites-available.

For example I have a site configured in there like this:

<VirtualHost *:80>
    DocumentRoot /usr/share/agendav/web/public
    ServerName agendav.mysite.tld

    # Logfiles:
    CustomLog /var/log/apache2/access_agendav.log combined
    ErrorLog /var/log/apache2/error_agendav.log
    LogLevel warn

    <Directory /usr/share/agendav>
            Options Indexes
            DirectoryIndex index.php
            php_flag magic_quotes_gpc Off
            php_flag magic_quotes_runtime Off
    </Directory>

</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /usr/share/agendav/web/public
    ServerName agendav.mysite.tld
    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key

    # Logfiles:
    CustomLog /var/log/apache2/access_agendav_ssl.log combined
    ErrorLog /var/log/apache2/error_agendav_ssl.log
    LogLevel warn

    <Directory /usr/share/agendav>
            Options Indexes
            DirectoryIndex index.php
            php_flag magic_quotes_gpc Off
            php_flag magic_quotes_runtime Off
    </Directory>

</VirtualHost>

As you see the Directory directive is redundant in both http and https part of the site. Is it valid to move the Directory directive at the beginnung so it is valid for both blocks or do I have to keep it in there twice?

Thanks!

© Server Fault or respective owner

Related posts about apache2

Related posts about config