Home  »  ArticlesGuidesSoftwareTechnology   »   How to Enable mod_headers in Apache Ubuntu | Debian

How to Enable mod_headers in Apache Ubuntu | Debian

There are a bunch of useful Apache modules that allow users to control and modify HTTP requests and response headers from the Apache server. Today you will learn how to enable mod_headers in Apache Ubuntu and Debian-based Linux systems.

Apache modules need to be enabled before you can use them. Some are enabled by default on installation while others must be enabled explicitly before use. Using a feature from a module that has not been enabled would result in an Internal Server Error. mod_headers is already installed in Apache (httpd) on Redhat/Fedora/CentOS distros by default.

Enable mod_headers

You can enable any Apache module, in this case, mod_headers, using the a2enmod command in the format:

$sudo a2enmod <module_name>

This would be the actual command to run:

$ sudo a2enmod headers

Next, restart the Apache webserver for changes to take effect:

$ sudo systemctl restart apache2

Check if mod_headers have been enabled and working using these:

$ apachectl -M | headers


$ apache2ctl -M | grep headers

With a similar line to this in the output:

headers_module (shared)

What if I Want to Disable mod_headers

If you want to disable any Apache module including mod_headers, you need to run the a2dismod command:

$ sudo a2dismod headers

Restart Apache webserver to apply changes.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Available under:
Articles, Guides, Software, Technology