Home » Enable MPM Event in Apache on Centos

Enable MPM Event in Apache on Centos

How to Enable MPM Event in Apache on Centos (using EasyApache4)

The MPM or (Multi-Processing Module) selected by you on your server affects several things including how Apache binds to network ports, accepts http requests and dispatches child processes to handle the http requests. The MPMs allow users to select the characteristics or modules that they want to include with a server request. The modules included will load these requests at compile or run time.

All the MPMs that come with Apache are not the same and due to these differences, some might work better than the others on specific systems. If you are working with older systems that require stability and compatibility then you must use work Prefork. Due to the self-regulatory nature of Prefork, it rarely required to adjust its configuration directives. However, if your website requires more scalability and diversity, you must opt for MPM worker or event. The defaukt MPM that is included with easy Apache4 is Prefork because of its compatibility with older systems. So, if you do not select a MPM, Prefork will continue to run on your server. There are several situations where you would like to change from one MPM to another or switch from Prefork to Event. Several hosts also recommend using a threaded MPM like Worker or Event.

Each of the three MPMs available on Apache has its own benefits. However, changing MPMs is an easy process. Since Prefork is the default option, if you need to switch to MPM Event, you will need to make some changes.

Login to WHM as root user and search for EasyApache4.

When the EasyApache4 interface has loaded, select to customize the current profile. It will load the options to install and uninstall modules, select PHP versions and extensions as well as add other packages.

The option to select PHP MPM loads at first and so, you will see there four options for MPMs. However, while there are only there independent options which include Prefork, Worker and event. The MPM Itk module is not actually an MPM and you can use it only with Prefork.

To install, MPM Event, you will need to uninstall the default MPM, Prefork. Toggle the button next to Prefork to uninstall it. Toggle the button next to MPM Event to install it. That’s all for now. Now, click on Review at the bottom on the left-hand side.

It will bring up the changes before you to Review before finally provisioning the new package. You will see that EasyApache 4 also uninstalls the conflicting modules and installs the supported modules when you change from MPM Prefork to MPM Event. It will uninstall mod_cgi and install mod_cgid. When you have reviewed the information, click on provision and let the process run. It will take a few minutes to provision the package and once the process is complete, it will inform you that provisioning has completed.

If you check again inside the currently installed packages, you will now see that MPM Event is highlighted in green and the toggle button next to it is on as in the image below.

Another method to change the MPM is to uncomment the line for the selected module inside the Apache configuration file. For example, MPMs can also be built as DSO modules and loaded into the server like the other DSO modules. It allows the MPMs to be changed using the LoadModule directive. You can simply uncomment the following line if you want to select Prefork:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Or you can uncomment the one for MPM Event and comment out the other two:

#LoadModule mpm_worker_module modules/mod_mpm_worker.so

LoadModule mpm_event_module modules/mod_mpm_event.so

#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Remember, you should comment out the LoadModule directives for the MPMs you are not planning to use. You can LoadModule only one MPM at a time, otherwise it will result in an error, that looks like this:

AH00534: httpd: Configuration error: More than one MPM loaded.

You can also use the yum shell command to switch MPMs.

As in the example below, you can run the following command to remove MPM worker and instal MPM Event:

yum shell

remove ea-apache24-mod_mpm_worker

install ea-apache24-mod_mpm_event

run

MPM Event is built on MPM worker and offers some additional benefits. So, there are no conflicts between these two in terms of modules and switching from one to another is simple. However, if you are trying to switch from Prefork to one of the two other modules or vice versa, you will also need to remove the conflicting modules.

In case, you need to revert to Prefork from event, you can use the below yum shell command:

yum shell

remove ea-apache24-mod_mpm_event

remove ea-apache24-mod_cgid

install ea-apache24-mod_mpm_prefork

install ea-apache24-mod_cgi

run

To switch from MPM Prefork to MPM Event,

yum shell

remove ea-apache24-mod_mpm_prefork

remove ea-apache24-mod_cgi

install ea-apache24-mod_mpm_event

install ea-apache24-mod_cgid

run

MPM Prefork works with mod_cgi , whereas the other two work with mod_cgid. You have more than one methods available to change MPM. However, the easiest and safest method is to do it via EasyApache4 interface from the WHM and use the other ones only if it does not work.