Get a List of All Static and Dynamic/Shared Modules Available and Enabled in Apache HTTP Server

The code powering all the feature set of the Apache Web Server is actually split across multiple modules that are binary libraries. This means we can develop and add features to Apache in the form of these modules and add them either statically or dynamically. What’s the difference ?

  1. Static Modules – These are compiled into the httpd binary when it is compiled and built. So static linking is when external libraries are compiled and added to the executable itself.
  2. Dynamic/Shared Modules – These are compiled libraries included dynamically at runtime. So dynamic linking is when external libraries are compiled and only a link to them is added to the executable. This is useful because when a module has to be updated, the entire executable (httpd) doesn’t have to be recompiled and rebuilt.

Here’s a list of all the modules that ships with the Apache HTTP Server distribution. Some of the well known ones that you’d also now relate to are:

  • core – Core HTTP features that are always available (includes all the directives that you know of and more).
  • mod_rewrite – Rewrites requested URLs on the fly.
  • mod_log_config – Setup access logs.
  • mod_auth_basic – Provides HTTP Basic authentication.
  • mod_env – Set environment variables which is then passed down to scripts as well.
  • mod_proxy – Helps setup reverse proxies.

So how does one find a list of all the static modules compiled into the server and the dynamically loaded ones as well ? The apachectl command which is a frontend to the Apache HTTP Server to perform administrative tasks can help us here.

# # List of Static Modules compiled in
# apachectl -l
Compiled in modules:

# # List Static and Shared/Dynamic Modules currently loaded/enabled
# apachectl -D DUMP_MODULES # or apachectl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 php7_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 status_module (shared)

Do note that the first command lists all the modules that were compiled into httpd where as the second one shows all static and dynamic modules that are currently loaded (not all the ones that are currently “available for use”).

In Debian/Ubuntu at least, you can find all the “available for use” shared modules in the mods-available folder of your server root whereas mods-enabled contains those that are currently picked up by the server on start/restart (output of shared modules in the second command above). So just do an ls over those two folders and you’ll know!

How can we load some new shared modules dynamically by ourselves ? By making use of the LoadModule directive! For instance, this is what the load config for mod_rewrite looks like:

LoadModule rewrite_module /usr/lib/apache2/modules/

So given you know the module name and location, all you need to do is put it up in the main configuration file (or some file that is included there) in the right syntax:

LoadModule module filename

Leave a Reply

Your email address will not be published. Required fields are marked *