I’ve had some experience with Apache 2, mostly adding aliases. For the multi-blog setup for WordPress, I wanted to use virtual document roots, but still be able to set up aliases for the main website.
For example, I want chris.northfolk.ca or christine.northfolk.ca or john or tim or whoever.northfolk.ca to use a virtual document root specified /var/srv but www.northfolk.ca to use the default /var/www for a document root and still be able to add aliases for www.northfolk.ca that aren’t available for the blogs.
In the end, it was very simple, but took several hours to figure out (as is usually the case). All I had to do was rename /etc/apache2/sites-enabled/000-default to 002-default. Then specify ServerName www.northfolk.ca under the VirtualRoot section. I also removed the NameVirtualHost heading because Apache will report an error if this exists twice and specify port 80 becuase Apache does not allow * and *:80 to coexist.
#NameVirtualHost *
ServerName www.northfolk.ca
ServerAlias northfolk.ca
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
…
Then I created a new file 001-wordpress to allow for virtual document roots:
NameVirtualHost *:80
UseCanonicalName Off
VirtualDocumentRoot /srv/www/%0
Options All
Options FollowSymLinks
AllowOverride All
Apache will try to match the virtual server with the higher number file first, then fall back to the lowest number file. So if the hostname is www.northfolk.ca or northfolk.ca Apache will use the 002 file, and if it is anything else it will fall back to the 001 file. This will allow me to add new blogs without having to modify the Apache configuration files. I only need to add a link at /var/srv/