How to Enable mod_headers module in Apache



I was working on side project, I need to set headers in .htaccess. But it was causing 500 Internal server error. After googling few minutes, I found that setting headers never throws 500 error. Then I thought it must be mod_headers apache module issue.

I looked at my code again and found that headers line is not wrapped in <If module>. After wrapping it, it was not affecting. then I checked that if my apache mod_headers module is enable or not. Here below is how we can enable mod_headers or any module of apache.

Enable any module in Apache

To enable any module in apache enter following command in Terminal:

sudo a2enmod <module_name>

Enable mod_headers

replace by actual module name.  Like in our example, I want to enable mod_headers.c module, I will use ‘headers’ (it’s actual name). So command becomes:

then, we have to restart apache to make changes. Fire following command to restart apache.

Enjoy !!!


Shyam Makwana has written 19 articles

I am PHP developer with passion of exploring IT world for new technologies. I do projects in WordPress, Joomla, Magento, Drupal, Open Cart, Code Igniter, MVC and CorePHP. Checkout my profile here to know more about me.