Apache on Ubuntu/Debian

Apache on Debian. Ubuntu

When I first started using Ubuntu, I was coming from a distro journey that started with FreeBSD and took in Mandrake and Gentoo along the way; I hadn’t worked with any Debian-based systems before and was new to the way that Apache is configured on those platforms.

Mainstream Settings

The Apache configuration is all in /etc/apache2/ – and while I do have an httpd.conf file in that directory, it is empty. I’ve got an apache2.conf which holds the global settings for the web server and also states which other items to include.

Modules

There are two directories which deal with modules. One is /etc/apache2/mods-available/ – this holds the .load files for the various modules which are available on this system, with the LoadModule commands appropriate to each. Some modules also have a .conf file here, if there are additional settings to go with them.

The other directory is /etc/apache2/mods-enabled, which contains only symlinks – these are .load files which link to the same-named .load file in /etc/apache2/mods-available, but only load files specified here in the mods-enabled directory will ever be loaded.

Sites

The sites setup follows a similar model to the Modules. All configuration files are held in the /etc/apache2/sites-available directory, the name of the file doesn’t matter. The files here contain the <VirtualHost> tags, rather than scattering these in httpd.conf or other locations.

There is a sister directory, /etc/apache2/sites-enabled which contains only symlinks, pointing back at the sites-available directory. Basically this allows you to turn sites on and off in a painless and controlled manner, without losing the configuration or having confusing comment blocks appearing. I find this very clean and usable, helping keep the various independent sites, well, independent.

Ubuntu and Apache

It took me a while to settle to using this system but I now find it clean and modular. I never did find any great documentation on how it works and too often I fall over examples where someone hasn’t understood what’s going on … so I thought I’d write it down in case it helps. Do you love or hate this “unique” setup – and why? Leave me a comment.

6 thoughts on “Apache on Ubuntu/Debian

  1. I’ve nearly always used Debian and Ubuntu, but went through a 2 year phase of using Fedora. I find Ubuntu’s setup very simple in comparison – much simpler than other distros I’ve used. I picked it up with hardly any reading, but the drawback is that when you come to another system (we use CentOS in our office, so I get confused when I can’t find the configs!). Both “systems” have advantages and disadvantages, but simply doing a2enmod/a2ensite to enable a site is pure gold in my opinion. Nice write-up, gives a good summary of the differences.

  2. I assume you know about the ‘apachectl’ command, which you can use, amongst other things, to verify the syntax of your config files (apachectl configtest)

    The ‘status’ and ‘fullstatus’ options will also tell you exactly what the server is doing if it seems to be slow or is refusing connections. There’s a directive for that as well so you can view the same thing on the web: http://httpd.apache.org/docs/2.0/mod/mod_status.html

    Like James says, it’s a pain that CentOS do it differently – but the main thing you need to remember is that CentOS use ‘httpd’ instead of ‘apache’ for all the directories and commands. I’ve come across other people’s servers where both seem to have been installed (not sure how) which gets *very* confusing…

    Four reasons I stick with Debian:
    (a) familiarity
    (b) it’s nice and reliable, they always delay the latest version if they need to fix bugs / improve stability
    (c) it has many more packages than CentOS – about 22,000 compared to 10,000.
    (d) ease of upgrading

  3. I recently switched over to Ubuntu too, so I went through the same process of figuring out the apache structure they use. It took some getting used to, but in the end I agree with you: It keeps things nicely separated and is easy to work with.

  4. <3 the Debian way. I too come from FreeBSD, and I still do have servers which run FreeBSD, Solaris, and maintaining one that runs CentOS. Somehow, once I got used to "the Debian way", the rest seems clunky and not clean at all. Worse yet, I've recreated the debian setup on the CentOS machine :)

  5. I remember I lost I was when I switch from Fedora to Ubuntu. Now that I’m use to the Ubuntu way I really prefer it.

    It makes it easy to turn on and off sites and modules. Especially if you use the a2ensite, a2dissite, a2enmod and a2dismod commands.

    I also like the way you have 2 php.ini. One for cli and one for apache.

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.