The Apache HTTP Server, commonly referred to as Apache, is one of the most widely used web servers. It offers a modular architecture, allowing users to extend its functionality by adding modules. These modules can range from security enhancements, like SSL/TLS encryption, to additional features, such as URL redirection or proxy capabilities.

By default, Apache comes with a set of core modules that cater to most basic web hosting needs. However, as websites grow and require more advanced features, administrators often need to install additional modules to meet these demands. For instance, the mod_rewrite module allows for URL manipulation, while the mod_proxy module provides proxy and caching functionalities.

Different Linux distributions provide various ways to manage and install Apache modules. Ubuntu and Debian derivatives for example use the apt package manager, RedHat-based distributions like CentOS and Fedora use the yum or dnf package manager, and SUSE uses zypper.

Steps to install Apache modules:

  1. Launch terminal.
  2. Update apt and dnf package list.
    $ sudo apt update # Ubuntu and Debian
    $ sudo dnf check-update # CentOS, Fedora and Red Hat
    $ sudo zypper refresh # SUSE
  3. Search for available Apache modules for your distribution.
    $ sudo apt search libapache2-mod- # Ubuntu and Debian
    [sudo] password for user:
    Full Text Search... Done
    libapache-mod-jk-doc/jammy/en 1:1.2.46-1 all
      Documentation of libapache2-mod-jk package
    
    libapache2-mod-apparmor/jammy/en 2.13.3-5ubuntu1 amd64
      changehat AppArmor library as an Apache module
    ##### snipped 
    $ sudo yum search mod_ # CentOS, Fedora and Red Hat
    [sudo] password for user:
    ============================== Name Matched: mod_ ==============================
    mod_md.x86_64 : Certificate provisioning using ACME for the Apache HTTP Server
    mod_ssl.x86_64 : SSL/TLS module for the Apache HTTP Server
    mod_ldap.x86_64 : LDAP authentication modules for the Apache HTTP Server
    ##### snipped
    > sudo zypper search apache2-mod # openSUSE and SLES
    [sudo] password for user:
    Loading repository data...
    Reading installed packages...
    
    S | Name                     | Summary                               | Type   
    --+--------------------------+---------------------------------------+--------
      | apache2-mod_apparmor     | AppArmor module for apache2           | package
      | apache2-mod_auth_gssapi  | GSSAPI Module for Apache              | package
      | apache2-mod_auth_openidc | Apache2.x module for an OpenID Conn-> | package
      | apache2-mod_authn_otp    | Apache module for one-time password-> | package
    ##### snipped
  4. Install required Apache modules for your distribution.
    $ sudo apt install --assume-yes libapache2-mod-security2 # Ubuntu and Debian
    $ sudo yum install --assumeyes mod_security # CentOS, Fedora and Red Hat
    > sudo zypper install apache2-mod_php7 # openSUSE and SLES

    Some Apache modules such as for PHP will be installed by default by installing the main package (PHP in this example) in distributions such as CentOS and Red Hat derivatives.

  5. Enable installed modules if it's not automatically enabled.
  6. Restart Apache to start using the installed module.
    $ sudo systemctl restart apache2
  7. Verify the module is loaded.
    $ apache2ctl -M | grep security
Discuss the article:

Comment anonymously. Login not required.