Chapter 4. Working with Apache modules
The httpd service is a modular application, and you can extend it with several Dynamic Shared Objects (DSO). You can dynamically load or unload DSO modules at runtime as necessary. You can find these modules in the /usr/lib64/httpd/modules/ directory.
4.1. Loading a dynamic shared object module Copy linkLink copied to clipboard!
To configure the functionality for the Apache HTTP Server, you can load Dynamic Shared Object (DSO) modules. You need to use the LoadModule directive to load a particular DSO module. A separate package has modules with their own configuration file stored in the /etc/httpd/conf.modules.d/ directory.
Prerequisites
-
You have installed the
httpdpackage.
Procedure
Search for the module name in the configuration files in the
/etc/httpd/conf.modules.d/directory:grep mod_ssl.so /etc/httpd/conf.modules.d/*
# grep mod_ssl.so /etc/httpd/conf.modules.d/*Copy to Clipboard Copied! Toggle word wrap Toggle overflow Uncomment the
LoadModuledirective of the module in the configuration file where the module name is present:LoadModule ssl_module modules/mod_ssl.so
LoadModule ssl_module modules/mod_ssl.soCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the module was not found, for example, because a Red Hat Enterprise Linux (RHEL) package does not include the module, create a configuration file, such as
/etc/httpd/conf.modules.d/30-example.confwith the following directive:LoadModule ssl_module modules/<custom_module>.so
LoadModule ssl_module modules/<custom_module>.soCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
httpdservice:systemctl restart httpd
# systemctl restart httpdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the module is loaded and enabled:
httpd -M | grep ssl
# httpd -M | grep sslCopy to Clipboard Copied! Toggle word wrap Toggle overflow
4.2. Compiling a custom Apache module Copy linkLink copied to clipboard!
You can create your own module and build it by using the httpd-devel package, which has the include files, the header files, and the Apache Extension (apxs) utility required to compile a module.
Prerequisites
-
You have the
httpd-develpackage installed.
Procedure
Build a custom module:
apxs -i -a -c module_name.c
# apxs -i -a -c module_name.cCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
- Load the module the same way as described in Loading a DSO module.