Apache2 on Ubuntu

I was installing Trac on Ubuntu the other day and I was really impressed with the new (well new as far as I’m concerned) Apache file layout.

In order to load modules you no longer have to add a LoadModule directive to the main config file. Instead, when you install a module using apt-get a file call <module_name>.load is created in the directory /etc/apache2/mods-available. If the module has any configuration associated with it then a seperate file called <module_name>.conf is also created in the same directory. To enable the module you create a symbolic link to each of these two files in the directory /etc/apache2/mods-enabled. When Apache starts it simply includes all the files in this directory. The commands a2enmod and a2dismod can manage all this for you if you don’t want to create/remove the links yourself, e.g. sudo a2enmod userdir, sudo a2dismod userdir.

Virtual hosts are managed in a very similar fashion. To create a new virtual host create a file in the directory /etc/apache2/sites-available containing the VirtualHost directive. To enable this host you create a symbolic link to this file in the directory /etc/apache2/sites-enabled. The commands a2ensite and a2dissite can manage all this for you, e.g. sudo a2ensite subversion.