How to disable an Apache Httpd module?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 10
  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 8
  • Red Hat JBoss Core Services Apache HTTP Server
    • All Versions

Issue

  • How to disable an Apache Httpd module?
  • How to check if an Apache Httpd module is disabled?
  • How to prevent an Apache Httpd module from loading?

Resolution

  • In this example, the http2_module is used, but the same steps apply to other Apache modules.
  • Search for the LoadModule directive related to the target module in Apache configuration files.
# grep http2_module /etc/httpd/conf/httpd.conf /etc/httpd/conf.modules.d/*.conf
/etc/httpd/conf.modules.d/10-h2.conf:LoadModule http2_module modules/mod_http2.so
  • If no line is returned or the LoadModule line is already commented out (i.e., starts with #), the module is not loaded.
  • If the module is loaded, comment out the LoadModule line in the corresponding configuration file by adding a # at the beginning of the line.
  • The line should look like this after the change.
# grep -w mod_http2 /etc/httpd/conf.modules.d/10-h2.conf
#LoadModule http2_module modules/mod_http2.so
  • In addition to commenting/disabling the desired Httpd module, also comment/disable any directives belonging to the Httpd module in question (as they are no longer valid).
  • After modifying the configuration, reload the Apache service to apply the changes:
# systemctl reload httpd.service

Diagnostic Steps

  • Use the apachectl -M command to list the loaded modules and verify if the target module is active.
  • The module name corresponds to the first parameter after the LoadModule directive; in this example, it is http2_module.
  • If http2_module appears in the list, the module is enabled:
# httpd -M | grep -w http2_module
 http2_module (shared)
  • If no output is returned, the http2_module is disabled:
# httpd -M | grep -w http2_module
#
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.