Improve Virtual Host File

How can I improve this virtual host file. It seems really redundant for my sub domains.


<VirtualHost *:80>
        DocumentRoot /var/www/jasonbiondo.com/jasonbiondo.com
        ServerName jasonbiondo.com

         <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot /var/www/jasonbiondo.com/dev.jasonbiondo.com
        ServerName dev.jasonbiondo.com

         <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot /var/www/jasonbiondo.com/fun.jasonbiondo.com
        ServerName fun.jasonbiondo.com

         <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot /var/www/jasonbiondo.com/stock.jasonbiondo.com
        ServerName stock.jasonbiondo.com

         <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

Jason,

They’re supposed to be! Each subdomain is treated as a separate domain with the www being default. Each can be hosted on a different server and each can have its own DocumentRoot, i.e., it’s all required.

As for the <Directory> entries, they appear to repeat server configurations so, if you modify the server, they will be inherited (and your vhosts entries can change the default from the server). If they’re set as you have them in the server, you can delete these as redundant.

Regards,

DK

DK,

How do I set this to be configured on my server? What are the advantages / disadvantages?

Jason,

Edit the httpd.conf (in the directory above the extras where the httpd-vhosts.conf file resides). Search that file for each of those core directives and set appropriately then save the file back to the server and restart Apache. The advantage is that those directives need to be read only once, not for each pass through the .htaccess (each .htaccess in the path) multiple times (until no further matches are discovered) for each file request (yes, including the css, js, jpg, gif, etc., files!). Get the message? Not to move that to the server’s config file is an abuse of the server (and, IMHO, should never be tolerated on a shared server).

Regards,

DK