"The Right Way" to enable modules / virtualhosts in Apache

Debian systems (and perhaps others) have the following layout in /etc/apache2/

mods-available/   mods-enables/   sites-available/   sites-enabled/

The default setup has a tonne of files in both mods-available and sites-available, and then there are symlinks to those files in *-enabled/.

I've never bothered with the symlinks. I've always just moved the files.

I argue that this allows you to easily see which mods/sites have been enabled, and which have not. The symlinks only let you see which have been enabled (easily, anyway, without resorting to diff). However, my colleague believes differently.

So, what is The Right Way and why?


The "Right Way" is to use a2enmod & a2dismod to enable and disable modules, a2ensite & a2dissite to enable and disable sites.

The a2*mod commands present you with a list of [disabled|enabled] modules that are installed on your system which you can then [enable|disable]. Same with the a2*site commands, however they work with the list of site configuration files (both those avaliable by default and those you have created) in the sites-avaliable directory.

You can also manually symlink from *-avaliable to *-enabled, but those commands are provided and are pretty much doing that anyway.

Example output of a2enmod:

Your choices are: actions alias asis auth_basic auth_digest authn_alias 
    authn_anon authn_dbd authn_dbm authn_default authn_file authnz_ldap authz_dbm 
    authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache 
    cern_meta cgi cgid charset_lite dav dav_fs dav_lock dbd deflate dir disk_cache dump_io 
    env expires ext_filter file_cache filter headers ident imagemap include info ldap 
    log_forensic mem_cache mime mime_magic negotiation pagespeed php5 proxy proxy_ajp 
    proxy_balancer proxy_connect proxy_ftp proxy_http proxy_scgi reqtimeout rewrite setenvif 
    speling ssl status substitute suexec unique_id userdir usertrack version vhost_alias
Which module(s) do you want to enable (wildcards ok)?

I am always a fan of creating home directories for virtual hosting accounts. This has a couple of advantages like easy chroot with ftp and ssh and of course the permissions are easier to manage.

I dont think there is a "right" way, there are different ways and everybody has their own methods.

One thing is for certain. I dont like the way debian (or Ubuntu) apache servers configure virtual hosts. I like the CentOS install of apache.

You can get a view of my kind of setup in my generate virtual hosts script (https://github.com/metalmini/vhostusers/blob/master/vhostusers.sh)