5

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?

4 Answers 4

11

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)?
2
  • 1
    That's the "really" correct way, +1.
    – weeheavy
    Sep 21, 2011 at 10:10
  • Fair point :-) I've used it in the past but always reverted just to working with the files.
    – user95415
    Sep 21, 2011 at 10:25
2

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)

0

Is there any point in having a list of disabled modules? Surely the relevant factor is whether or not the server supports something, and you can tell that by looking at whether it is in the enabled list or not.

1
  • Chances are that you won't use it, totally right. But when symlinks offer no other features or benefits (that I can think of) you might as well, imo. Another advantage too: you can immediately see which sites/mods are custom from the base install of Apache as they're not symlinks whereas the default modules are.
    – user95415
    Sep 21, 2011 at 9:57
0

Enabled always is symlinks to avail.

So you always have full-list, and works-now-list. Also symlinks may have name like 001-site, Client-id-12-site etc, so some kind of structure.

Also you need not do changes in tons of place. Change one file only.

Also its just looks pretty.

And i doesnt see any negatives with this structure, so why not? ;)

3
  • If you move the files instead of symlinking, you have a "works now" list, an "available" list and - if you ls both directories together - a full list too. When you move a file, you only need to change in one place too. It just looks pretty? Could say the same about moving the files. There are no negatives with that approach, but there are potentially more positives with moving the files.
    – user95415
    Sep 21, 2011 at 10:53
  • From the Zen of Python, I quote: "There should be one-- and preferably only one --obvious way to do it."
    – user95415
    Sep 21, 2011 at 12:33

You must log in to answer this question.