Apache is a widely used web server with a modular architecture. This design allows administrators to enhance its functionality by adding or removing specific Apache modules. These modules include features such as SSL/TLS encryption, URL redirection, and proxy capabilities.
By default, Apache comes with essential modules suitable for basic web hosting. However, more complex websites often require additional modules. Examples include mod_rewrite for URL manipulation and mod_proxy for proxy services.
The process of installing Apache modules varies depending on the Linux distribution. Ubuntu and Debian use apt, while CentOS and Fedora use yum or dnf. SUSE employs zypper for managing packages.
Steps to install Apache modules:
- Open the terminal.
- 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
- 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
- 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.
- Enable the installed module if not automatically enabled.
- Restart Apache to apply the changes.
$ sudo systemctl restart apache2
- Verify that the module is loaded.
$ apache2ctl -M | grep security
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.