This post is part of ‘Speed up Moodle’, a 4 post series showing ways to optimize a Moodle server. By default, Apache loads modules that might not be needed for your Web server. In this third post, I show you how to disable the unnecessary Apache modules to run a bare bones Moodle installation.
Disclaimer: I am not a professional server administrator but I have looked after Moodle servers for several years now, and never experienced major issues. What I am sharing has worked for me, but might not work for you. You’ve been warned!
Why it matters
The more RAM Moodle has access to, the faster it will run and the more users it will be able to serve (if configured properly). It is therefore important for the Web server to use as little RAM as possible, so that more users can be served at the same time. As explained in a previous post, every Apache process uses a specific amount of RAM, and the more Apache modules are loaded, the more RAM each process will use. As Apache processes are run concurrently, the RAM savings are roughly proportional to the amount of processes run simultaneously.
Note: whilst other Moodle users have reported saving significant amounts of RAM disabling unnecessary modules, the gains have been small for me (just over 1MB per process).
Loaded Apache modules
Before you disable Apache modules, you need to get a list of all the Apache modules that are currently loaded on your server. For this, use the following command:
apache2ctl -t -D DUMP_MODULES
It will return a list similar to this:
Loaded Modules: core_module (static) log_config_module (static) logio_module (static) mpm_prefork_module (static) http_module (static) so_module (static) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) mime_module (shared) negotiation_module (shared) php5_module (shared) reqtimeout_module (shared) setenvif_module (shared) status_module (shared)
The modules labelled as (static) cannot be disabled. The list above represents all of the modules loaded on a default installation of Ubuntu 12.04 LTS.
Disabling unnecessary modules
The command to disable an Apache module is simple. Note that depending on your situation, it may be unwise to disable some modules (e.g. deflate). You can find a description of what each module does on the Apache documentation page.
sudo a2dismod <em>name_of_module</em> sudo service apache2 restart
sudo a2dismod status sudo service apache2 restart
Here is the command to disable all unnecessary modules on a default Ubuntu 12.04 LTS server:
sudo a2dismod authz_groupfile authz_default auth_basic authn_file authz_user cgi deflate env negotiation reqtimeout setenvif status
If you wish to re-enable the modules, simply type:
sudo a2enmod authz_groupfile authz_default auth_basic authn_file authz_user cgi deflate env negotiation reqtimeout setenvif status
Don’t forget to restart your Apache server for the changes to take effect:
sudo service apache2 restart
Here is the list of modules that must be loaded on your Web server to run a default installation of Moodle (doesn’t mean it’ll run fastest). Note that your situation may vary. Read the technical notes here to check if your system is similar to the one I used for testing.
apache2ctl -t -D DUMP_MODULES Loaded Modules:core_module (static) log_config_module (static) logio_module (static) mpm_prefork_module (static) http_module (static) so_module (static) alias_module (shared) authz_host_module (shared) autoindex_module (shared) dir_module (shared) mime_module (shared) php5_module (shared)
It is important to test prior making changes, and after the changes. This is the only way you’ll find whether it has made a difference. You can run your own tests using this great utility programme. You can follow this guide to install it.
In the next article, I will explain how to install APC opcode cache.