How To: Enable apache modules under Debian based system
Apache is usually suitable out of the box for most common used. The apache structure under debian based systems is actually really well made as it is really easy to activate or deactivate module.
This how-to will show how to activate or deactivate available modules under a debian system running apache2.
1. How it works
There is 2 kinds of modules used by apache:
- Modules compiled in
- Modules that are loaded when you launch apache
In order to check which modules were compiled in with apache, you can type the following command:
$ apache2 -l
Compiled in modules:
core.c
mod_access.c
mod_auth.c
mod_log_config.c
mod_logio.c
mod_env.c
mod_setenvif.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_negotiation.c
mod_dir.c
mod_alias.c
mod_so.c
This list correspond to the modules compile with apache on an Ubuntu Dapper system. As you can see, there is no php, rewrite…. modules compiled in. Those modules are meant to be included when running apache.
Now, let check the main apache configuration file, namely /etc/apache2/apache2.conf, around line 115, you can see those 2 lines:
# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
As you can see, apache load any files ending with .load first and .conf after, in /etc/apache2/mods-enabled/.
Now, let’s have a look in that directory:
$ ls /etc/apache2/mods-enabled/
actions.load php5.conf rewrite.load userdir.load
cgi.load php5.load userdir.conf
As you can see, I have cgi, actions, php5, userdir and rewrite modules enabled. This allow me to run an php5 scripts in /home/user/public_html using rewriting rules.
Going further up into the investigation, we can see that files in mods-enabled are not actually files, but links to files contained in mods-available:
ls -l /etc/apache2/mods-enabled/userdir.load
lrwxrwxrwx 1 root root 30 2006-05-15 03:00 /etc/apache2/mods-enabled/userdir.load -> ../mods-available/userdir.load
Now, let’s have a look at /etc/apache2/mods-available:
ls /etc/apache2/mods-available/
actions.load dav_fs.conf info.load proxy.load
asis.load dav_fs.load ldap.load rewrite.load
auth_anon.load dav.load mem_cache.load speling.load
auth_dbm.load deflate.load mime_magic.conf ssl.conf
auth_digest.load disk_cache.load mime_magic.load ssl.load
auth_ldap.load expires.load php5.conf suexec.load
cache.load ext_filter.load php5.load unique_id.load
cern_meta.load file_cache.load proxy.conf userdir.conf
cgid.conf headers.load proxy_connect.load userdir.load
cgid.load imap.load proxy_ftp.load usertrack.load
cgi.load include.load proxy_http.load vhost_alias.load
This basically contains all the files linked by mods-enabled plus a whole load of available modules.
Now, let see how to add a module.