How to Disable Unneeded Apache Modules

Apache HTTP Server is a robust choice for a web server because it is modular. You can conceivably add an unlimited number of modules to Apache to extend functionality, security, or added features. Furthermore, many Linux distributions include numerous Apache modules by default. In some cases you might not even use them.

Modules that are not needed just make loading times longer and can occupy your dedicated server resources that you could otherwise divert elsewhere. Fortunately, disabling modules is not difficult.

Debian-based systems come with two useful scripts for enabling or disabling server modules.

  • a2enmod enables modules in apache2 by creating symlinks with /etc/apache2/mods-enabled
  • a2dismod disables the modules by removing the symlinks.

To disable a module called “mod_serverschool”, enter as root:

a2dismod mod_serverschool

To re-enable the module, type:

a2enmod mod_serverschool

In Red Hat Enterprise Linux (RHEL), CentOS, and other derivatives, you must edit the configuration file in /etc/httpd/conf.d/. Each module’s conf file will be stored there. Therefore, if you do not need the mod_serverschool module, you would rename “serverschool.conf” to “serverschool.bak” and then restart Apache:

mv serverschool.conf serverschool.bak
service httpd restart

To re-enable the module, rename the .bak file back to .conf:

mv serverschool.bak serverschool.conf
service httpd restart

Now that you know how to enable and disable Apache modules, it is important to know what modules do before you start disabling anything you might actually need. Even if you think you may understand a module’s function, it might have another. You can search the Apache module registry for the module in question to find out more about it. Finally, if something goes wrong after you disable a module, you can always enable it again.











Comments: