Linux disable unneeded modules in Apache to save memory

by on August 27, 2007 · 3 comments· LAST UPDATED August 27, 2007

in , ,

Q. How do I disable unneeded Apache modules under Debian Linux?

A. You can disable all unneeded modules in Apache to save memory and improve performance. This may also result into improved security. Different Linux distribution follows different methods for disabling modules.

Debian / Ubuntu Linux disable a module

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

(b) 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.

Syntax:
a2dismod {module-name}

For example disable a module called foo or mime_magic, enter:
# a2dismod foo
# a2dismod mime_magic

Enable a module again

If you ever need to re-enable disabled modules, use a2enmod command as follows:

Syntax:
a2enmod {module-name}

For example, enable imagemap module, enter:
# a2enmod imagemap

Note if don't know module name, it will show a list of all available modules:
# a2enmod
Output:

Which module would you like to disable?
Your choices are: alias auth_basic authn_file authz_default authz_groupfile authz_host authz_user autoindex cgi dir env fastcgi mime negotiation php5 setenvif status userdir
Module name?  authz_user

CentOS / Redhat (RHEL) / Fedora Linux disable a module

Under Redhat based Linux distributions you need to modify *.conf file stored in /etc/httpd/conf.d/ directory. Apache scans for files with the .conf suffix at start up.

So if the system does not need to use mod_python, rename 'python.conf' to 'python.bak' and restart Apache with the command 'service httpd restart in order to disable that particular module and save memory.
# cd /etc/httpd/conf.d/
# mv perl.conf no.perl.bak
# /etc/init.d/httpd restart

Enable a module

To re-enable modules, simply rename them to their original names and restart Apache to get back module functionality:
# cd /etc/httpd/conf.d/
# mv no.perl.bak perl.conf
# /etc/init.d/httpd restart

More about /etc/httpd/conf.d/ directory

This directory holds Apache 2.0 module-specific configuration files; any files in this directory which have the ".conf" extension will be processed as Apache configuration files. Files are processed in alphabetical order, so if using configuration directives which depend on, say, mod_perl being loaded, ensure that
these are placed in a filename later in the sort order than "perl.conf".

  • manual.conf : This configuration file allows the manual to be accessed at http://localhost/manual/
  • perl.conf : mod_perl incorporates a Perl interpreter into the Apache web server, so that the Apache web server can directly execute Perl code.
  • php.conf : php5 module for php
  • proxy_ajp.conf : When loaded, the mod_proxy_ajp module adds support for proxying to an AJP/1.3 backend server such as Tomcat.
  • python.conf : mod_python is a module that embeds the Python language interpreter within the server, allowing Apache handlers to be written in Python.
  • squid.conf : Access to squid cache manager
  • ssl.conf : Apache SSL server configuration
  • webalizer.conf : Webalizer stats configuration
  • welcome.conf : This configuration file enables the default "Welcome" page if there is no default index page present for
    the root URL.
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 3 comments… read them below or add one }

1 Darko Bunic August 1, 2008 at 7:25 am

You can disable even more modules from httpd.conf configuration file. Default apache setup loads DAV, Proxy, Speling, Ldap modules and they are needless for LAMP setup. I wrote more about it on http://www.redips.net
Thanks you!

Reply

2 Darko Bunic June 24, 2009 at 6:17 am
3 billy December 17, 2014 at 9:51 pm

thank for information
this rename will disable modules?

Reply

Leave a Comment

Tagged as: , , , , , , , , , ,

Previous Faq:

Next Faq: