How to Enable and disable apache modules

For  Debian / Ubuntu Linux 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. For centos and other redhat based distributions we don`t use a2enmod and a2dismod, but  another  methode is used to enable and disable modules in apache.apache


For  Debian / Ubuntu Linux

Ubuntu and debian comes with two scripts:
  1-a2enmod is a script that enables the specified module within the apache2 configuration. It does this by creating symlinks within /etc/apache2/mods-enabled.

2- a2dismod disables a module by removing those symlinks. It is not an error to enable a module which is already enabled, or to disable one which is already disabled.

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.

pirat9@pirat9-pc:~$ 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 /etc/init.d/apache2 restart

For Centos/Fedora and other redhat based linux distribuntions:

For centos/ fedora and other redhat based distributiosn, things work different than in Ubuntu/ Debian, you need to modify *.conf file stored in /etc/httpd/conf.d/ directory. So for example if you don`t want to use the module expire, to disable this module, you need to rename  expire.conf to mod_expire.bkp and then restart apache.

If you want to enable the module  again simply rename it to it original name and then restart apache.

Example: To enable module expire, we need to rename mod_expire.bkp to the original name :  mod_expire The command will be:

 # cd /etc/httpd/conf.d/
# mv mod_expire.bkp expire.conf
# /etc/init.d/httpd restart

{loadposition user9}

  • Nick

    Debian has a built in function for enabling (linking) mods and sites
    # a2enmod rewrite
    will enable mod_rewrite
    # a2ensite default
    will enable your default site
    restart or reload apache2 to see changes
    # apache2ctl restart

  • Yoolia

    Thx a lot!

  • Jonathan García

    Good explaining!!

  • Diễn Huỳnh Văn

    great ! thanks you :D

  • Pingback: » Linux ubuntu apache 限制頻寬()

  • Pingback: Preparing Ubuntu system for WordPress installation. | aMi on Rails()

  • cheap michael kors

    Aegean cats are medium sized with a muscular build. The coat of the cat is not short or too bushy, rather it can be considered as a semi longhaired cat. The coat of the cat comes in a variety of hues. Some of them are bicolor, others tricolor. The major dominating color is always white. The white shows little or no signs of yellowing and covers up 1/3 to 2/3 of the coat. Other colors found on the coat of the Aegean are black, red, blue, and cream. Some cats are also found to come with tabby striping. The cats have medium in sized paws that are round in shape. The ears of the Aegean generally have a wide base with tips that are rounded and covered by hairs. The eyes of the Aegean are shaped like an almond and the color of eye varies from the lightest to the brightest tinge of green.

  • michael kors outlet online

    A naturally developed cat that has survived the test of time they are immune to most diseases that other cats are prone to. They tend to be sturdy and not easily affected by common ailments, thus, very suitable as pets as not much care is needed for their health.

  • cheap Christian Louboutin

    Unlike common cats, the Aegeans do not have any phobia relating to water. Rather they are noted for being attracted to water and are skilled in fishing.