How to enable Apache 2 modules
Posted by admin on July 21 2008 10:51:47

The Apache2 HTTP Server is a modular program, where we can choose its functionality by including in the server a set of modules.
The modules can be statically compiled into the httpd binary when the server is built. Alternatively, modules can be compiled as
Dynamic Shared Objects (DSOs) that exist separately from the main httpd binary file.

Normally enabling one particular apache DSO module will involve editing the main apache configuration file and
adding a LoadModule line to enable the loading of the particular module. Depending from the module itself, we might need to add
also some configuration directives. This will work fine on Debian also,
but I am going to show you the Debian particular method of managing apache2 modules.

Regardless of the apache MPM (Multi-Processing Modules) you are using: apache2-mpm-prefork, apache2-mpm-worker or
apache2-mpm-perchild after the installation you will end up with some default modules: some already enabled and some ready to be used.
Opposed to a RedHat based system for example (where they will try to enable all the possible modules) the Debian package will enable
by default only a very small amount of modules.
Here are the modules enabled by default:

Compiled statically inside the apache2 binary: core, http_core, prefork/worker/perchild, mod_access, mod_auth, mod_log_config,
mod_logio, mod_env, mod_setenvif, mod_mime, mod_status, mod_autoindex, mod_negotiation, mod_dir, mod_alias, mod_so.

You can get the list of compiled in modules from the command line with, apache2 -l
These modules can’t be disabled without recompiling the apache package
For more details on the build-in modules you can check Appendix 1.
Standard apache2 modules installed and ready to be enabled: actions, asis, auth_anon, auth_dbm, auth_digest, auth_ldap,
cache, cern_meta, cgi, cgid, dav, dav_fs, deflate, disk_cache, expires, ext_filter, file_cache, headers, imap, include, info,
ldap, mem_cache, mime_magic, proxy, proxy_connect, proxy_ftp, proxy_http, rewrite, speling, ssl, suexec, unique_id,
userdir, usertrack, vhost_alias.

only one module is enabled by default: mod_userdir
You can enable any of these modules at any time with as shown bellow.
For more details on the standard modules installed you can check Appendix 2.
Other apache2 modules available: you can install additional apache2 modules that are not standard if needed. Probably
you will like to have php installed that way, but maybe some others based on the particular need. The installation uses the
regular apt commands, for example:

aptitude install libapache2-mod-php4
The list of additional modules that can be installed includes: mod-geoip, mod-jk, mod-mono, mod-perl2,mod-php4, mod-php5,
mod-python, mod-rpaf, mod-ruby, mod-suphp.

For the full list of extra modules available you can check Appendix 3.
Normally when you install one of the extra modules the debian package will automatically enable it. If needed, you can
disable it as shown bellow (if you don’t want to completely remove it).
Managing apache2 modules in Debian:
The Debian apache2 package provides a unique mode of managing modules. All the loading and configuration related entries
are found in individual files inside folder /etc/apache2/mods-available/. Here we will find files like module_name.load
(and if needed module_name.conf). Also all additional installed modules will place their configuration files in the same place.

Inside the folder /etc/apache2/mods-enabled/ we will find all the enabled modules. Here we will find symlinks to the files
from mods_available for all the enabled modules. Only the modules found in this folder will be enabled at run time.

For example the configuration file for mod_rewrite includes only one line to load the module:
cat /etc/apache2/mods-enabled/rewrite.load
LoadModule rewrite_module /usr/lib/apache2/modules/
So in order to enable one additional module we will only have to create the proper symlinks from the mods-available to the mod-enabled files…
But why not use the little tools Debian provides us for this:

a2enmod: enables an apache2 module (this does nothing else but creates the proper links to the module .load and .conf files). For example
to enable the rewrite module:
a2enmod rewrite
a2dismod: disables an apache2 module (removes the links from mod-enabled for the module). For example to disable the rewrite module: a2dismod rewrite
Running a2enmod without any parameter will show the possible choices:

Which module would you like to enable?
Your choices are: actions asis auth_anon auth_dbm auth_digest auth_ldap cache cern_meta cgi cgid dav dav_fs deflate disk_cache
expires ext_filter file_cache geoip headers imap include info ldap mem_cache mime_magic php4 proxy proxy_connect proxy_ftp proxy_http
rewrite rpaf ruby speling ssl suexec unique_id userdir usertrack vhost_alias
Module name?

Running a2dismod without any parameter again will show us the list of enabled modules and allow to choose one:

Which module would you like to disable?
Your choices are: actions cgi deflate geoip headers info php4 rewrite rpaf ruby
Module name?

To enable the modules you need to enter the a2enmod command, followed by the name of requested module:

#a2enmod module_name

If you don't remember the name of the module you have to enabled, you should simply not enter any parameters after a2enmod command:


In this case, you receive a list which show disabled modules, as following example:

Which module would you like to enable? Your choices are: actions alias asis auth_basic auth_digest authn_alias authn_anon authn_dbd 
authn_dbm authn_default authn_file authnz_ldap authz_dbm  authz_default authz_groupfile authz_host authz_owner authz_user
autoindex cache cern_meta cgid cgi charset_lite dav_fs dav  dav_lock dav_svn dbd deflate dir disk_cache env expires userdir
usertrack version vhost_alias Module name?

After module activation, it's necessary to apply the changes made, by running a restart of the server, usually via the command:

#/etc/init.d/apache2 force-reload

To install the mod_rewrite you have to type following commands:

#a2enmod rewrite #/etc/init.d/apache2 force-reload

How to disable Apache 2 modules

The process of deactivation of the module, with relative cancellation of his symbolic
link in the directory /etc/apache2/mods-enabled/, is quite similar to that previously shown for activation. The command
used this time is a2dismod, which can be followed by module name or used without parameters for a list of options.
In first case, the code will be as follows:

#a2dismod module_name

In second case, simply type


to receive the list of enabled modules, for example:

Which module would you like to disable? Your choices are: alias auth_basic authn_file authz_default authz_groupfile
authz_host authz_user  autoindex cgi dav dav_svn dir env mime negotiation php5 rewrite  setenvif ssl status userdir Module name?

Keywords: apache enable rewriting, module activation, deactivate apache module, mod-rewrite, mod-rewrite activation, apache modules, disable modules apache