How to List Enabled Apache Modules: Commands and Methods


3 views

The simplest way to list enabled Apache modules is by using the -M or -t -D DUMP_MODULES flag with the Apache binary. Here are the common commands:


# For Apache 2.4+ (most common)
apache2ctl -M
# Alternative syntax
httpd -M

# For older Apache versions
apachectl -t -D DUMP_MODULES

If you have PHP running with Apache, you can use:


<?php
print_r(apache_get_modules());
?>

You can also check which modules are enabled by examining these files:


# Debian/Ubuntu
/etc/apache2/mods-enabled/

# RHEL/CentOS
/etc/httpd/conf.modules.d/

For scripting purposes, you might want to process the module list:


#!/bin/bash
# Get sorted module list
apache2ctl -M | awk '{print $1}' | sort

To see both loaded and available modules:


# On Debian-based systems
apache2ctl -t -D DUMP_MODULES 2>&1 | grep -E '^\s*[a-z]'

# On RHEL-based systems
httpd -l  # Shows compiled-in modules
httpd -M  # Shows loaded modules

Note that module availability depends on:

  • Apache version (2.2 vs 2.4 vs 2.5)
  • OS distribution (Debian vs RHEL)
  • Compilation method (DSO vs static)

The easiest way to list enabled Apache modules is by using the -M or -t -D DUMP_MODULES flag with the Apache binary:

# For most Linux distributions:
apache2ctl -M

# Alternative syntax:
apache2ctl -t -D DUMP_MODULES

# For some older systems:
httpd -M

The command will display output like this:

Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_event_module (static)
 ...

Key indicators in the output:

  • (static) - Compiled directly into Apache
  • (shared) - Dynamically loaded module

Using PHP

If you have PHP installed with Apache:

<?php
print_r(apache_get_modules());
?>

Checking Configuration Files

Look for these directives in configuration files:

# Main configuration usually in:
/etc/apache2/apache2.conf
/etc/httpd/httpd.conf

# Module-specific files in:
/etc/apache2/mods-enabled/
/etc/httpd/conf.modules.d/

When you might need this information:

  • Debugging module conflicts
  • Verifying security configurations
  • Preparing for server migration
  • Performance optimization

To verify if mod_rewrite is enabled:

apache2ctl -M | grep rewrite

Or for multiple modules:

for module in rewrite ssl headers; do
    apache2ctl -M | grep $module || echo "$module NOT loaded"
done