How to Enable mod_headers module in Apache

apache-server

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:

sudo a2enmod headers

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

service apache2 restart

Enjoy !!!

 

Shyam has written 29 articles

Shyam is senior full stack developer, who loves to explore new technologies and work on them. He's passionate about coding so can code 24/7. He uses PHP as a backend programming language.

He knows Laravel, MySQL, AngularJS, ReactJS, Redis, Kubernetes, Git, CodeIgniter, PHP, MVC pattern, Lodash, jQuery, VanilaJS, Teamcity and many other technologies and tools.

Shyam writes notes and hacks on his blog (https://shyammakwana.me). In spare time he can be found @ StackOverflow or crafting any new open source application.

Passionate Programmer and Meditator #PERIOD.