[HowTo] Enable or disable modules in Apache

You can enable or disable any apache module using a2enmod and a2dismod. You don’t need to edit the conf file for that unless you are having some problem with this method. The syntax of these commands is really simple:
To enable a module:

sudo a2enmod module_name

To disable a module:

sudo a2dismod module_name


For instance, to enable mod_expires, execute sudo a2enmod expires in the terminal. If you see the following output, you can be sure that it has been enabled.

[email protected]:~$ sudo a2enmod expires
Enabling module expires.
Run '/etc/init.d/apache2 restart' to activate new configuration!

To disable mod_expires:

sudo a2dismod expires

Restart the server after enabling the module.

sudo service apache2 restart

Or

sudo /etc/init.d/apache2 restart

PS: On linux systems, you can use auto-complete feature by pressing tab with a2enmod and a2dismod. It will show list of mods installed on your system.

Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *