Maintaining apache2 sites and modules lists
Posted by chris on Mon 8 Aug 2005 at 20:17
This brief introduction for configuring sites and modules in Debian's Apache 2 package explains how to add and remove sites using the supplied tools, along with adding and removing modules.
The main source of confusiong comes from the various directories stored beneath /etc/apache2:
- sites-available
- A list of configuration files - one per site. A blank install will contain the file default. The system admin can have as many sites here as they need - however - they will not all be active.
- sites-enabled
- A list of symlinks to configuration files in sites-available. A blank install will contain a symlink 000default to sites-available/default. The sites listed here are the sites which will be active. The site to be used if no virtual hosts match will be the first file found (hence the 000 on 000default).
- mods-available
- A list of configuration files - one or more per module. Each dpkg installed module will add files here. e.g. php4.conf and php4.load are added with the libapache2-mod-php package. Again - the system admin can install whatever modules they wish - however - until they are set available they will not be active.
- mods-enabled
- A list of symlinks to configuratioon files in modes-available. Only modules linked in here will be activated on the webserver.
Now - several discussions on #debian IRC channel on freenode recently have had people advising others to either copy files from the available to the enabled directories or to manually symlink them. The user has, however, a better option - the four commands a2ensite, a2dissite, a2enmod and a2dismod
- a2ensite
- Will create the correct symlinks in sites-enabled to allow the site configured in sitefilename to be served
- a2dissite
- Will remove the symlinks from sites-enabled so that the site configured in sitefilename will not be served
- a2enmod
- e.g. a2enmod php4 will create the correct symlinks in mods-enabled to allow the module to be used. In this example it will link both php4.conf and php4.load for the user
- a2dismod
- Will remove the symlinks from mods-enabled so that the module cannot be used
We covered these this new layout briefly when discussing the upgrade from Apache 1.x to 2.x, and again when dicussing how to enable mod_rewrite for Apache.
Just supposing for the moment that someone had done the symlinks by hand, could terribly things befall their website if they switched to using these tools in future?
[ Parent | Reply to this comment ]
If all you've done is manually create the symlinks - then apache won't be able to tell the difference.
All the tools do is provide some level of automation (e.g. for the php4 example above - making sure that you don't link the .conf file and forget the .load file)
If you've copied the files - or worse - only have the files in the -enabled directories then it may get confused (don't know since I haven't tried).
I try to think of the -enabled directories being for apache's use and the -available directories being for my use :) Apache only looks in the -enabled directories to see what's there. I can have whatever I want in the -available directories - switching them in and out as needed.
I added the article mainly to have something to point to when the discussion comes up on #debian - there is more info in the other debian-administration articles in the links and in the /usr/share/doc directories.
[ Parent | Reply to this comment ]
Did you always wonder the point of the 3 leading zeros in 000-Default? Now I know why.
When using virtual hosts, the default site has to be the first one Apache "sees". If you rename it, whenever the user tries to access a disabled-site, (with DNS still pointing to your box), well, what it does is: it will drop to the next file, alphabetically. VERY annoying.
Bottom line: keep the leading zeros. They come first alphabetically, and they have a good reason to exist.
And cheers for the article, didnt know of these scripts.
Alex,
admin at tribelodge dot com
[ Parent | Reply to this comment ]
Oddly - the 000default is the one file I don't control with the a2en/a2dis scripts. These scripts take site names and work on filename matching. I removed the site "default" from available since I have 19 real virtual hosts. I have manually symlinked the 000default one to the main host so - for that host and that host alone there are two symlinks from the sites-enabled directory.
[ Parent | Reply to this comment ]
Fernando
[ Parent | Reply to this comment ]
[ Send Message | View Steve's Scratchpad | View Weblogs ]
This should help, as it shows how the a2ensite + a2dissite tools are used to manage multiple virtual hosts.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]