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:
1 2 | |
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:
1
| |
- a2dismod: disables an apache2 module (removes the links from mod-enabled for the module). For example to disable the rewrite module:
1
| |
Running a2enmod without any parameter will show the possible choices:
1 2 3 4 | |
Running a2dismod without any parameter again will show us the list of enabled modules and allow to choose one:
1 2 3 4 | |
Don’t forget to reload the apache daemon, after making any changes to the list of enabled modules:
/etc/init.d/apache2 reload