mod_headers is a useful Apache module that allows you to control and modify HTTP request and response headers in Apache. If you try to modify headers in Apache web server without installing mod_headers, it may throw an internal server error. Here’s how to enable mod_headers in Apache Ubuntu/Debian. You can also use it to enable mod_headers in Cpanel, WordPress. However, mod_headers is already installed in httpd on Redhat/Fedora/CentOS, by default.
How to Enable mod_headers in Apache Ubuntu
Here’s how to enable mod_headers in Apache Ubuntu / Debian.
1. Install mod_headers
If you want to install Apache module such as mod_headers, you need to issue the a2enmod command
$ sudo a2enmod <module_name>
Open terminal and run the following command.
$ sudo a2enmod headers
2. Restart Apache Web Server
Restart Apache web server for changes to take effect
$ sudo service apache2 restart
Bonus Read : How to Enable Keep Alive in Apache
3. Check if mod_headers is working
You can easily check if mod_headers is enabled by running the following command
$ apachectl -M | headers
$ apache2ctl -M | grep headers
If you see the following output, it means mod_headers is enabled and working.
$ headers_module (shared)
Bonus Read : How to Change Port Number in Apache
4. Disable mod_headers
If you want to disable/uninstall Apache module such as mod_headers, you need to issue the a2dismod command
$ sudo a2dismod <module_name>
To disable/uninstall mod_headers run the following command.
$ sudo a2dismod headers
Restart Apache web server to apply changes.
That’s it! Now you can easily install, enable and disable mod_headers in Apache web server.