Apache virtual hosts, _default_ and ServerName
I’ve recently changed my VPS provider. I won’t go into why, that’s a separate post for when I find the time and nerves to write about it.
Given the opportunity of the move, I decided to split my VirtualHost configuration out of a single httpd.conf file into per virtual-host config files. This by chance, is something that I knew that I could do since 1696 but never really realized the advantages of doing so before now.
Anyway, the mistake I made was to assign ServerName in httpd.conf to either a named or aliased VirtualHost. This caused a conflict which was solved as soon as I changed ServerName to something totally irrelevant.

This is one thing I love about Debian, everything is nicely set up for per-VirtualHost configuration files out of the box. It gives you a directory to create all the VirtualHost files in (/etc/apache2/sites-available/, with “default” being the only one out of the box), and command-line helper utilities (a2ensite / a2dissite) to enable and disable VirtualHosts (essentially just makes a symlink to it in /etc/apache2/sites-enabled). It works pretty well
.
Not too sure what other Linux distributions do this out of the box, I don’t use any others (except for CentOS, but I only use CentOS when I use cPanel).
in Red Hat / Fedora based distributions you’d get something like a main configuration directory and an additional one (/etc/httpd/conf.d/). Any .conf file in the additional directory will be loaded as part of Apache configuration. Then it all depends on you. Some people create a separate .conf file for each virtual host (rename a file to a non-.conf extension to disable the loading of it on Apache restart). Some other people create a single configuration file where they store all of their VirtualHosts. Some other people group VirtualHost based on some criteria (client ID, etc).
I do appreciate this flexibility. You can organize things differently on each server, depending on your current needs, but everything is similar enough and easy to make sense of by someone who haven’t wrote the configuration.
That is interesting… a colleague of mine once argued that the Ubuntu path was easier to remember and shorter than the Fedora one. Let’s see…
I see nothing wrong with either and I have no preference of one over the other, but the Fedora one does look shorter to me and of course, I remember it because I use it.