Do you use let's encrypt?





7703 votes ~ 25 comments

 

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.

 

 


Re: Maintaining apache2 sites and modules lists
Posted by simonw (193.237.xx.xx) on Tue 9 Aug 2005 at 18:05
[ View Weblogs ]
Ah I did wonder.

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 ]

Re: Maintaining apache2 sites and modules lists
Posted by Anonymous (84.48.xx.xx) on Tue 9 Aug 2005 at 18:54
It depends.

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 ]

Re: Maintaining apache2 sites and modules lists
Posted by Anonymous (24.226.xx.xx) on Fri 12 Aug 2005 at 18:14
BTW, maybe it's a bit off-topic, but here is one issue I've had, because I tweaked Apache 2 too much:
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 ]

Re: Maintaining apache2 sites and modules lists
Posted by chris (217.8.xx.xx) on Tue 16 Aug 2005 at 15:09
[ View Weblogs ]
True - I had mentioned that under sites-enabled - but it's good to reinforce the point.

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 ]

Re: Maintaining apache2 sites and modules lists
Posted by nano (198.60.xx.xx) on Sun 16 Oct 2005 at 07:14
Hi, I read the information in this page, but I am still puzzled with the new way to configure apache2. I have only one server and I would like to know what specifically I need to edit in the files under apache2 to make my webserver to work. Please help.

Fernando

[ Parent | Reply to this comment ]

Re: Maintaining apache2 sites and modules lists
Posted by Steve (62.30.xx.xx) on Thu 6 Jul 2006 at 22:13
[ View Steve's Scratchpad | View Weblogs ]

This should help, as it shows how the a2ensite + a2dissite tools are used to manage multiple virtual hosts.

Steve

[ Parent | Reply to this comment ]

Re: Maintaining apache2 sites and modules lists
Posted by Anonymous (200.87.xx.xx) on Tue 8 Apr 2008 at 03:42
if you want to learn more about apache2 download the “Apache2 bible� http://tips-debian.blogspot.com/2008/04/apache-bible.html

[ Parent | Reply to this comment ]

a2avsite + a2avmod?
Posted by Anonymous (70.53.xx.xx) on Wed 14 May 2008 at 15:24
Would be nice to add more utilies that abstracts the addition of, e.g., the actual site to the site-available folder. This way, in deploying one can just run the utility without having to hard code, e.g., /etc/apache2/sites-available in its deployment script. Subtle point, but with a2en* scripts already there, ones that work in the available dirs seem appropriate to complete the picture.

[ Parent | Reply to this comment ]

Re: a2avsite + a2avmod?
Posted by Anonymous (41.234.xx.xx) on Fri 23 Jan 2009 at 16:17
hi every one
i have abig problem iam working now on my graduation project whic i must enable the ssl on apatch server 2.2 i just Generate, a certificate then i do't know what 2 do really i am stucking :s can't under stand any artical i wannna some ome help me step by step telling me 1 2 3 so i can under stand

[ Parent | Reply to this comment ]

Re: Maintaining apache2 sites and modules lists
Posted by Anonymous (82.33.xx.xx) on Tue 5 Oct 2010 at 19:12
I have modified the apache2 configuration file to allow me to put all my web files on an external usb disk. Unfortunately a2ensite etc seems to be hard wired to look at files only at the conventional location /etc/apache2/...

Is there a workaround for this lack of convention?

[ Parent | Reply to this comment ]