How To Enable or Disable Modules in Apache Web Server

The Apache HTTP Server’s (HTTPD) feature set can be extended by a ton of modules. Modules can be either static or shared/dynamic. Static modules are “in effect” or enabled by default but the shared ones have to be explicitly enabled. Enabling and disabling modules has to be done via configurations. We just need to know where the Apache configurations and the module files (to be loaded) are located.

Enable/Disable Modules

As far as any Unix-based or Unix-like operation systems go, like Mac OS, FreeBSD or Linux distros (Ubuntu, Debian, Fedora, CentOS, etc.), enabling or disabling an HTTPD module is just a LoadModule entry away. In this article we will learn how to:

  1. Find the module file path.
  2. Find the module identifier.
  3. Pass (1) and (2) to the LoadModule directive to enable the module.

Step 1: Finding Module Path

By default the Apache server installation ships with a bunch of modules that are all available somewhere, but just a few enabled. These modules exist as so (shared object) files. We need to find the location of this so file first.

One of the easiest way to do that is to first find out two things:

On running apachectl -V (or httpd -V) on my macOS, this is what I get:

 -D HTTPD_ROOT="/usr"
 -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

So my server root is /usr and the main server config location is /private/etc/apache2/httpd.conf. As you can see they are on separate paths which is ok. In linux distributions you may find them on similar paths like this:

 -D HTTPD_ROOT="/etc/apache2"
 -D SERVER_CONFIG_FILE="apache2.conf"

When the server config path is relative (apache2.conf), it’ll be relative to the server root path which is /etc/apache2. Hence in this case the full path for main server config is /etc/apache2/apache2.conf.

Once we know the full path to main server config, the next thing we need to do is simply cd into the “apache2” or “httpd” folder path in that and grep for LoadModule. On my local that is /private/etc/apache2 where as on a linux distribution, it’ll be something like /etc/apache2 or /etc/httpd depending upon the HTTPD_ROOT and SERVER_CONFIG_FILE values dumped above. Anyway, let’s do the cd and grep.

~ % cd /private/etc/apache2
/private/etc/apache2 % grep -ir 'LoadModule' .
./httpd.conf:# LoadModule foo_module modules/
./httpd.conf:#LoadModule mpm_event_module libexec/apache2/
./httpd.conf:LoadModule mpm_prefork_module libexec/apache2/
./httpd.conf:#LoadModule mpm_worker_module libexec/apache2/
./httpd.conf:LoadModule authn_file_module libexec/apache2/
./httpd.conf:#LoadModule authn_dbm_module libexec/apache2/
./httpd.conf:#LoadModule authn_anon_module libexec/apache2/
./httpd.conf:#LoadModule authn_dbd_module libexec/apache2/
./httpd.conf:#LoadModule authn_socache_module libexec/apache2/
./httpd.conf:LoadModule authn_core_module libexec/apache2/
./httpd.conf:LoadModule authz_host_module libexec/apache2/
./httpd.conf:LoadModule authz_groupfile_module libexec/apache2/
./httpd.conf:LoadModule authz_user_module libexec/apache2/

As we can see there are a bunch of LoadModule lines with a module identifier and module path. The lines that are uncommented are the ones enabling the specified modules. The important things to note here is that the path for all of them are similar:


The module path can be absolute or relative to the server root which in my case is /usr. Hence the full path for a module will be /usr/libexec/apache2/<>. Let’s go to /usr/libexec/apache2/ and do an ls to see whats there:

~ % ls /usr/libexec/apache2

That’s it! We now know where the module files exist. To enable one of them, we’ll use their path from here.

Step 2: Finding Module Identifier

Now we need to find another bit of information, which is the module identifier to be used with LoadModule. This is super simple. Sometimes the grep that we did in the previous step may give you the answer but if not then we can simply go to the Apache documentation for any module where the identifier will be listed under the Module Identifier section or sub-heading.

For instance, the module identifier for <a href="">mod_proxy</a> is proxy_module.

mod_proxy documentation page

Step 3: Load the Module

With the module path and identifier in hand, we can finally put the LoadModule directive into the main server config followed by a server restart to load the module.

# In /private/etc/apache2/httpd.conf
# Syntax: LoadModule module-identifier module-file-path
LoadModule proxy_module /usr/libexec/apache2/

The file path can be either absolute or relative to the server root. Don’t forget to restart httpd after this change:

% sudo apachectl restart

Once the module is loaded and enabled, you can put any related configuration settings for it in the server config file directly. Another way is to put the module-related config in a separate file and include it in the main server config.


Some operating systems ship with utilities to make the entire process much more easier.


If you’re on Ubuntu or Debian, you can already see the list of available modules in the server root’s mods-available folder.

# ls /etc/apache2/mods-available/
access_compat.load    cache.load          heartbeat.load            negotiation.conf     rewrite.load

To enable them, you can use inbuilt utilities like a2enmod and a2dismod to enable and disable modules respectively.

$ a2enmod rewrite # Enable mod_rewrite
$ a2dismod rewrite # Disable mod_rewrite

Followed by a server restart:

$ service apache2 restart

I really like the mods-available and mods-enabled segregation in Ubuntu personally. It further segregates the module’s LoadModule directive and any default configuration into separate files. For example, these are the available files in mods-available or mods-enabled for mod_info:

$ cat mods-available/info.conf
<IfModule mod_info.c>

	# Allow remote server configuration reports, with the URL of
	#  http://servername/server-info (requires that mod_info.c be loaded).
	# Uncomment and change the "" to allow access from other hosts.
	<Location /server-info>
		SetHandler server-info
		Require local
		#Require ip


$ cat mods-available/info.load
LoadModule info_module /usr/lib/apache2/modules/

The two different files are then included in the main config file (apache2.conf). Much better organisation!

Leave a Reply

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