Performance Tuning Apache Web Server – Enabled Modules
There are many different aspects to tuning Apache. In this post, I will focus on tuning which modules are compiled into Apache and also dynamically enabled. The more modules you have enabled, the more memory Apache will consume and the more processing it needs to perform; try to enable the minimum amount of modules required on your Web server to improve performance and reduce memory consumption:
1) First, list which Apache modules you have enabled on your server:
apache2 -l — this will list all the compiled in modules
a2dismod — this will list all dynamically loaded modules
2) Decide which modules you can disable and disable them:
For the compiled in modules, the list for the compiled modules in Ubuntu’s Apache web server will look something like this:
Compiled in modules: core.c mod_log_config.c mod_logio.c prefork.c http_core.c mod_so.c
These are usually required modules. You may be able to do without these in certain circumstances:
mod_log_config.c — This module is required for logging. If you want to disable logging, you can do without. This is usually not recommended though.
prefork.c — This module is only needed if you use Apache’s prefork mode rather than using threaded workers.
If you determine that you can live without some of these modules, you can choose to recompile Apache without the unnecessary modules.
For the dynamically loaded modules, the output will look something like:
~$ a2dismod Your choices are: alias auth_basic authn_file authz_default authz_groupfile authz_host authz_user autoindex cgi dav dav_svn deflate dir env mime negotiation passenger php5 rewrite setenvif ssl status wsgi Which module(s) do you want to disable (wildcards ok)?
Which modules you require depend strongly on your application. Try to research what each module does and determine if it is required. Once you have determined that a module is not necessary, you can disable it via
sudo a2dismod [module name]
sudo /etc/init.d/apache2 reload
3) Recompile apache with only the needed modules?
Once you have your system narrowed down to the exact list of modules you need, you can gain a bit more performance by compiling them directly into apache rather than loading them dynamically. However, keep in mind that this makes future updating (security updates etc.) much more complex. Usually your time is better spent on other optimizations.