Apache is a widely used web server recognized for its modular architecture, allowing functionality to be extended by adding or removing specific Apache modules. These modules include features such as SSL/TLS encryption, URL rewriting, and proxy services.

Popular modules include mod_rewrite for URL manipulation, mod_proxy for reverse proxy functionality, and optional SSL/TLS components that secure connections. The default installation often includes only core modules, leaving others to be installed as necessary to meet advanced requirements.

Different Linux distributions use distinct package managers to install Apache modules. Ubuntu and Debian rely on apt, while CentOS and Fedora typically employ yum or dnf. SUSE uses zypper for managing packages, making familiarity with distribution-specific tools essential for maintaining and extending Apache functionality.

Steps to install Apache modules:

  1. Open the 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 in your distribution's repository.
    $ 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 the required Apache module.
    $ 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 the installed module if not automatically enabled.
  6. Restart Apache to apply the changes.
    $ sudo systemctl restart apache2
  7. Verify that the module is loaded.
    $ apache2ctl -M | grep security
Discuss the article:

Comment anonymously. Login not required.