Linux disable unneeded modules in Apache to save memory

Posted on in Categories , , , , last updated August 27, 2007

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.

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:

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

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.

Sun Solaris UNIX display list for loaded kenel device driver / modules

Posted on in Categories , , last updated August 20, 2007

Q. How do I display information about loaded kernel modules under Sun Solaris UNIX operating system?

A. You need to use modinfo command which is a trivial program to display information about the loaded modules. The format of the information is as follows:

Id Loadaddr Size Info Rev Module Name

where Id is the module ID, Loadaddr is the starting text address in hexadecimal, Size is the size of text, data, and bss in hexadecimal bytes, Info is module specific information, Rev is the revision of the loadable modules system, and Module Name is the filename and description of the module.

Task: Displaying the status of kernel modules

Just enter modinfo command:
You can pass -c option to modinfo command to display the number of instances of the module loaded and the module’s current state:
modinfo -c

Display information about particular module / driver only

You can also display information about particular module only by specifying its ID #:
modinfo -i 5
The above example displays the status of module # 5.

Read modinfo man page for other information and options.