Apache2 – Overview of configuration and files (draft)

The following is an overview of how to edit standard files, the directory structure and how to enable site features in apache2. Let’s first dig into the folders that comprise apache2.

Files

$tree -d /etc/apache2 #only show dirs
/etc/apache2/
|– conf.d
|– mods-available
|– mods-enabled
|– sites-available
`– sites-enabled

Let’s define the functions of each.

conf.d – configuration files for modules, etc.
mods-available – list of available modules for apache
mods-enabled – list of modules that are loaded into apache config
site-available – configuration files for virtual hosts
sites-enabled – ?

Files also listed in /etc/apache2…

|– apache2.conf
|– envvars
|– httpd.conf
|– magic
`– ports.conf

Enabling and Disabling Modules

First, check the available modules on your system.

/etc/apache2/mods-available/
|– actions.conf
|– actions.load
|– alias.conf
|– alias.load
|– asis.load
|– auth_basic.load
|– auth_digest.load
|– authn_alias.load
|– authn_anon.load
|– authn_dbd.load
…..

To view all mods enabled view the mods-enabled dir. Note that these are sym linked to the mods-avialable directory.

/etc/apache2/mods-enabled
|– alias.conf -> ../mods-available/alias.conf
|– alias.load -> ../mods-available/alias.load
|– auth_basic.load -> ../mods-available/auth_basic.load
|– authn_file.load -> ../mods-available/authn_file.load
|– authz_default.load -> ../mods-available/authz_default.load
|– authz_groupfile.load -> ../mods-available/authz_groupfile.load

Let’s say we want to enable ‘mod-security’. The best way to do this on ubuntu/debian is to use ‘a2enmod’ utility, which stands for apache2 enable module.

jesterj@jesterj-laptop:/etc/apache2$ sudo a2enmod ssl
Enabling module ssl.
See /usr/share/doc/apache2.2-common/README.Debian.gz on how to configure SSL and create self-signed certificates.
Run '/etc/init.d/apache2 restart' to activate new configuration!

Note: You can also just type ‘a2enmod’ to list all available modules.

Now restart apache.

jesterj@jesterj-laptop:/etc/apache2$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2 ... waiting [ OK ]

Now, verify the module is available.

jesterj@jesterj-laptop:/etc/apache2$ ls -la /etc/apache2/mods-enabled/ | grep ssl
lrwxrwxrwx 1 root root 26 2010-02-08 19:20 ssl.conf -> ../mods-available/ssl.conf
lrwxrwxrwx 1 root root 26 2010-02-08 19:20 ssl.load -> ../mods-available/ssl.load

To disable a module, do the same thing but use ‘a2dismod’.

Configuring Sites

Leave a Reply