Debian Lenny - Apache config layout

Debian Lenny uses a different Apache layout than you may have encountered if you have used Apache with non-Debian based Operating Systems.

The differences are not huge and, indeed, help in configuring and deploying websites.


Assuming you have used aptitude to install Apache (see the Debian Lenny Apache and PHP5 install article), move into the config folder and have a look:

cd /etc/apache2

You will see this:

Apache Configuration Directory

The folders are highlighted in blue. Let's look at those first:


Inside sites-available will be files containing the configurations for each site you want to serve - these are known as vhosts or virtual hosts.

Have a look now and see that there is one site (default) available:

ls sites-available/
default  default-ssl

The apache install has a 'default' and a 'default-ssl' vhost available - when we navigated to the Slice IP and got the 'It works!" message, it was the 'default' file that told Apache what to do and where the files where located.

We'll look at vhosts in more detail and create our own in a later article.

Do note that a file in sites-available does not mean they are active. They are simply available for serving if you enable them. Which brings us to...


This folder contains symlinks to the sites you actually want to serve.

For example, you could have two vhosts configured and ready to use in the sites-available folder, but only one of them enabled. Only the one symlinked from the sites-enabled folder would be served.

Have a look at the default contents:

ls -l sites-enabled
lrwxrwxrwx 1 root root 26 Nov 28 22:38 000-default -> ../sites-available/default

This means that the 'default' site has been enabled - the symlink named '000-default' links to the 'default' file in the sites-available folder.

Without the symlink in this folder it would remain available (in the sites-available folder) but not active.

The other thing to note is the naming. It's possible for a domain to point to your Slice IP but have no site configuration file. In these cases, the first enabled site (alphabetically) will be displayed, i.e. 000-default's config will be used.


Well, I guess you get the idea already but this folder holds the modules that are available to be loaded.

Have a look:

ls mods-available

A fair list is available from our base install but remember that they are not all enabled, merely available for use.

Just as with the vhosts files, any modules that we want to use must be enabled.


This folder contains symlinks to the modules that we want enabled. Have a look and compare it to the list of modules available:

ls mods-enabled

This list is a lot shorter than the list of available modules (meaning not all the available modules are enabled) and includes php5.conf - which is handy as we installed PHP5 earlier.

a2en and a2dis

Being good sysadmins, we like to get hands on and create our vhosts, and now that we know how the symlinks work we could go ahead and 'ln -s' until all our sites are enabled.

However, there are some commands that make this process much easier.

They are a2dissite, a2ensite, a2dismod and a2enmod.


This will delete the symlink to a site you have previously enabled.

For example, let's disable the default site:

sudo a2dissite default

The symlink in sites-enabled has been deleted and the output is as follows:

Site default disabled.
Run '/etc/init.d/apache2 reload' to activate new configuration!

Reload Apache as indicated to ensure the site is fully disabled:

sudo /etc/init.d/apache2 reload

When you now visit your Slice IP, instead of the nice 'It Works!' page, you will get a 404 Not Found message:

Apache Configuration Directory

Note the main vhosts file in sites-available is still there - all the a2dissite command did was remove the symlink in the sites-enabled folder.


Let's enable the default site again:

sudo a2ensite default

The output:

Enabling site default.
Run '/etc/init.d/apache2 reload' to activate new configuration!

Reload Apache:

sudo /etc/init.d/apache2 reload

Visit your Slice IP - the default 'It works!' page is being served again.


In the same way as just shown, a2dismod will disable any modules you have previously enabled:

sudo a2dismod php5

The output:

Module php5 disabled.
Run '/etc/init.d/apache2 restart' to activate new configuration!

That will disable the php5 module and if you look in the mods-enabled folder, you will see that the symlinks php5.conf and php5.load have been deleted.


I reckon you've got it now, but to enable the php5 module simply enter:

sudo a2enmod php5

The output:

Enabling module php5.
Run '/etc/init.d/apache2 restart' to activate new configuration!

And a quick check will show that indeed, the php5.conf and php5.load symlinks are back in the mods-enabled folder.


Don't forget to reload Apache after each site or module change.

In the next article we'll discuss the main apache2.conf file and look at what changes can be made to optimise the install.



Article Comments:

mya commented Mon Jun 22 10:26:09 UTC 2009:

Hey, I'm just wondering how you managed to use this fancy IP address..

mnttech commented Tue Jul 28 10:44:43 UTC 2009:

me too? How can you use this IP adress? At least give us just a link.

Ben B commented Thu Jul 30 22:27:12 UTC 2009:

That is not a real IP address, we are just using that for the sake of example.

depannage informatique commented Fri Oct 02 13:18:41 UTC 2009:

agree with ben

depannage informatique paris commented Wed Oct 21 22:02:12 UTC 2009:

i understand now.. i tried to use the IP provided... lol

installation portail commented Wed Nov 11 14:26:07 UTC 2009:

La concurrence est vraiment acharnée à se rechopper les endroits ou on peut claquer un backlink. (je suis mnttech et je parle de pcpourlesnuls et aformaclic)

depannage informatique colmar commented Tue Feb 02 12:02:19 UTC 2010:

Thank you for sharing !

Matias commented Wed Aug 18 14:19:33 UTC 2010:

Muy interesante el post. Sobre todo los comandos "a2ensite" y demas. Por si alguien no se dio cuenta y como ayuda memoria es bueno aclarar que por ejemplo "a2ensite" es por "apache 2 enable site" y lo mismo "a2dissite" es por "apache 2 disable site".

Alex commented Thu Aug 19 11:18:22 UTC 2010:

Merci beaucoup pour ce tutorial.


Stories commented Fri Aug 12 08:00:56 UTC 2011:

your site is superb. i foudn a lot more cool stuff here . Keep Posting

Aaron commented Sun Apr 14 09:43:04 UTC 2013:

Je viens juste d'utiliser ce tutoriel et ça marche du tonnerre! Merci d'avoir prit le temps pour l'écrire.

ls2013 commented Tue Aug 06 13:43:13 UTC 2013:

This is very interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your wonderful post. Also, I've shared your web site in my social networks!

ls2013 commented Tue Aug 06 13:45:09 UTC 2013:

This is very interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your wonderful post. Also, I've shared your web site in my social networks!

Want to comment?

(not made public)


(use plain text or Markdown syntax)