Apache is a widely-used open-source web server that supports various features through its modules. These modules can manage tasks like URL rewriting, security, and caching. Knowing which modules are installed or enabled is important for server management and application performance.

Listing modules in Apache helps in identifying active and available features on your server. This process is necessary when you need to optimize your server or troubleshoot issues. The methods to list these modules differ based on your operating system, such as Ubuntu or Red Hat based distributions.

Understanding the status of your Apache modules enables you to make informed decisions about your server's configuration. This guide explains how to list installed, enabled, and available modules in different Apache environments.

Steps to list installed, enabled or disabled Apache modules:

  1. List all enabled Apache modules.
    $ apache2ctl -M
    Loaded Modules:
    core_module (static)
    so_module (static)
    ...
    rewrite_module (shared)
    Module Type Description
    Static These are the modules that are compiled directly into the main httpd binary. They are always present and do not need to be loaded separately. The main advantage is performance, but the drawback is that adding or removing a static module requires recompiling Apache.
    Shared Shared modules are compiled as separate shared objects. They can be loaded or unloaded at runtime using directives in Apache's configuration file without recompiling the entire Apache binary. This makes adding or removing functionality more flexible.
    Dynamic These are similar to shared modules but are generally used to refer to modules that can be loaded or unloaded at runtime without a server restart. Typically, modern Apache installations use shared modules in place of truly dynamic ones.
  2. Filter for a specific module to check if it’s enabled.
    $ apache2ctl -M | grep rewrite
    rewrite_module (shared)
  3. List all available modules in the system.
    $ ls /etc/apache2/mods-available
    access_compat.load auth_basic.load ...
    authz_user.load rewrite.load

    This directory contains all the available modules on a Debian-based system. The location may vary depending on the distribution.

  4. List modules using a2query for a detailed view.
    $ a2query -m
    rewrite (enabled by site administrator)
    reqtimeout (enabled by maintainer script)
    env (enabled by maintainer script)
    deflate (enabled by maintainer script)
    negotiation (enabled by maintainer script)
    proxy_http (enabled by site administrator)
    authn_core (enabled by maintainer script)
    dir (enabled by maintainer script)
    authz_core (enabled by maintainer script)
    setenvif (enabled by maintainer script)
    autoindex (enabled by maintainer script)
    auth_basic (enabled by maintainer script)
    authz_host (enabled by maintainer script)
    alias (enabled by maintainer script)
    authz_user (enabled by maintainer script)
    access_compat (enabled by maintainer script)
    proxy (enabled by site administrator)
    filter (enabled by maintainer script)
    mpm_event (enabled by maintainer script)
    mime (enabled by maintainer script)
    authn_file (enabled by maintainer script)
  5. Confirm the status of a specific module using a2query.
    $ a2query -m rewrite
    rewrite (enabled by site administrator)
  6. List all available and enabled modules on Ubuntu systems.
    $ ls /etc/apache2/mods-*
    /etc/apache2/mods-available:
    access_compat.load    dir.conf                  proxy_express.load
    actions.conf          dir.load                  proxy_fcgi.load
    actions.load          dump_io.load              proxy_fdpass.load
    alias.conf            echo.load                 proxy_ftp.conf
    alias.load            env.load                  proxy_ftp.load
    allowmethods.load     expires.load              proxy_hcheck.load
    asis.load             ext_filter.load           proxy_html.conf
    ##### snipped
    
    /etc/apache2/mods-enabled:
    access_compat.load  authz_user.load  filter.load       proxy.conf
    alias.conf          autoindex.conf   heartbeat.load    proxy_http.load
    alias.load          autoindex.load   mime.conf         proxy.load
    auth_basic.load     deflate.conf     mime.load         reqtimeout.conf
    authn_core.load     deflate.load     mpm_event.conf    reqtimeout.load
    authn_file.load     dir.conf         mpm_event.load    setenvif.conf
    authz_core.load     dir.load         negotiation.conf  setenvif.load
    authz_host.load     env.load         negotiation.load
  7. List all available and enabled modules on CentOS systems.
    $ ls /etc/httpd/*modules*/
    /etc/httpd/conf.modules.d/:
    00-base.conf    00-dav.conf  00-mpm.conf       00-proxy.conf    01-cgi.conf  10-proxy_h2.conf
    00-brotli.conf  00-lua.conf  00-optional.conf  00-systemd.conf  10-h2.conf   README
    
    /etc/httpd/modules/:
    mod_access_compat.so    mod_cgid.so                 mod_log_config.so      mod_reflector.so
    mod_actions.so          mod_cgi.so                  mod_log_debug.so       mod_remoteip.so
    mod_alias.so            mod_charset_lite.so         mod_log_forensic.so    mod_reqtimeout.so
    mod_allowmethods.so     mod_data.so                 mod_logio.so           mod_request.so
    mod_asis.so             mod_dav_fs.so               mod_lua.so             mod_rewrite.so
    mod_auth_basic.so       mod_dav_lock.so             mod_macro.so           mod_sed.so
    mod_auth_digest.so      mod_dav.so                  mod_mime_magic.so      mod_setenvif.so
    ##### snipped

    Each of the configuration file might contain more than one LoadModule directives.

Discuss the article:

Comment anonymously. Login not required.