How to list all currently enabled apache2 modules on Linux server


How can I list all currently enabled modules using Apache2 webserver?


Using apache2ctl command with a combination of -M you can list all loaded apache modules on your system. For example the following linux command will list all loaded modules on separate lines:

# apache2ctl -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)
 geoip_module (shared)
 mime_module (shared)
 mpm_event_module (shared)
 negotiation_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 status_module (shared) 

Another alternative to the above command is:

# apache2ctl -t -D DUMP_MODULES

Another, but less reliable alternative is to list all enabled modules within /etc/apache2/mods-enabled/

# ls /etc/apache2/mods-enabled/
access_compat.load  auth_basic.load  authz_core.load  autoindex.conf  deflate.load  env.load     geoip.load  mpm_event.conf    negotiation.load  setenvif.load
alias.conf          authn_core.load  authz_host.load  autoindex.load  dir.conf      filter.load  mime.conf   mpm_event.load    rewrite.load      status.conf
alias.load          authn_file.load  authz_user.load  deflate.conf    dir.load      geoip.conf   mime.load   negotiation.conf  setenvif.conf     status.load

All listed modules above are enabled but may not yet be loaded as they only represent a symbolic link to its corresponding counterparts located within /etc/apache2/mods-available/. For example:

# ls -l /etc/apache2/mods-enabled/rewrite.load 
lrwxrwxrwx. 1 root root 30 Jun 23 02:32 /etc/apache2/mods-enabled/rewrite.load -> ../mods-available/rewrite.load

If you are searching for a particular loaded module simply redirect your STDOUT from apache2ctl command to grep command. For example let’s search whether rewrite and alias modules are currently loaded:

# apache2ctl -M | grep -E "rewrite|alias"
 alias_module (shared)
 rewrite_module (shared)

From the above output we can see that both rewrite and alias apache modules are loaded.