Apache is a modular system in a sense that its functionality could be extended by using modules. A module could be installed into the system and Apache would then be configured to load the module during its startup.

Some of the mostly used modules are PHP and SSL which is to enable support for hosting PHP applications and provide encrypted web traffic respectively.

Apache modules could be enabled and disabled where and when required.

Steps to enable or disable Apache modules:

  1. Install required Apache module if not not already installed.
  2. Check if desired module is already loaded or enabled (optional).
    $ apachectl -t -D DUMP_MODULES
    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)
     mime_module (shared)
     mpm_event_module (shared)
     negotiation_module (shared)
     reqtimeout_module (shared)
     setenvif_module (shared)
     socache_shmcb_module (shared)
     status_module (shared)

    You can also use the -M option instead which is just a shortcut to the above command.

    $ apachectl -M
  3. Add desired modules into Apache configuration file using the LoadModule directive.
    LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
    • Ubuntu and other Debian derivatives along with openSUSE and SLES has a2enmod utility installed and could be used to easily load Apache modules without having to manually configure the LoadModule directive.
      $ sudo a2enmod ssl
      [sudo] password for user:
      Considering dependency setenvif for ssl:
      Module setenvif already enabled
      Considering dependency mime for ssl:
      Module mime already enabled
      Considering dependency socache_shmcb for ssl:
      Module socache_shmcb already enabled
      Enabling module ssl.
      See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates.
      To activate the new configuration, you need to run:
        systemctl restart apache2
    • CentOS, Fedora and Red Hat distributions will automatically load the module so no further action is required.
    Options Debian, Ubuntu openSUSE and SLES Fedora Core, CentOS, RHEL macOS homebrew xampp
    a2enmod support yes yes no no no no
    Loadmodule directive n/a LoadModule <module_name>_module <module_location>/mod_<module_name>.so
  4. Restart Apache service for the modules to be loaded.
  5. Check if module is now enabled.
    $ apachectl -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)
     mime_module (shared)
     mpm_event_module (shared)
     negotiation_module (shared)
     reqtimeout_module (shared)
     setenvif_module (shared)
     socache_shmcb_module (shared)
     ssl_module (shared)
     status_module (shared)
  6. Remove the added LoadModule directive or comment out the line by adding # at the beginning to disable loading the module.
    #LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so

    Users of Ubuntu and other Debian derivatives along with openSUSE and SLES can use a2dismod utility to disable Apache modules.

    $ sudo a2dismod ssl
    [sudo] password for user:
    Module ssl disabled.
    To activate the new configuration, you need to run:
      systemctl restart apache2
  7. Restart Apache service for the modules to be unloaded.

Guide compatibility:

Operating System
Ubuntu 16.04 LTS (Xenial Xerus)
Ubuntu 16.10 (Yakkety Yak)
Ubuntu 17.04 (Zesty Zapus)
Ubuntu 17.10 (Artful Aardvark)
Ubuntu 18.04 LTS (Bionic Beaver)
Ubuntu 18.10 (Cosmic Cuttlefish)
Ubuntu 19.04 (Disco Dingo)
Share this guide!
Discuss the article:

Comment anonymously. Login not required.

Share!