Apache HTTP Server, one of the most widely used web servers globally, has the power to handle several clients concurrently. It accomplishes this via various Multi-Processing Modules (MPMs), affecting how Apache responds to network traffic. One such MPM, the Event MPM, is known for its high performance and ability to handle numerous simultaneous connections with minimal memory usage.
This article will guide you through the steps required to enable Event MPM in Apache on CentOS/RHEL.
Prerequisites
Before we start, ensure you have:
- CentOS/RHEL installed on your server
- Sudo or root privileges to run administrative commands
- Apache HTTP server installed
Step-by-Step Guide
Here are the steps to enable Event MPM in Apache:
Step 1: Checking the Current MPM
Start by checking which MPM is currently enabled in your Apache HTTP server. Use the following command:
httpd -V | grep MPM
This will display the current MPM in use. By default, the pre-fork MPM is usually enabled.
Step 2: Installing Event MPM
If the Event MPM isn’t enabled, you need to install it. Apache in CentOS/RHEL has a package that allows for easy installation. Use the following command to install:
sudo yum install httpd-event
This will install the Event MPM.
Step 3: Disabling the Current MPM
After installing the Event MPM, you need to disable the currently enabled MPM (usually pre-fork or worker). Open the Apache configuration file with a text editor:
sudo nano /etc/httpd/conf.modules.d/00-mpm.conf
Comment out the line of the currently enabled MPM, and uncomment the line for event MPM. The configuration should look like this:
1 2 3 | #LoadModule mpm_prefork_module modules/mod_mpm_prefork.so #LoadModule mpm_worker_module modules/mod_mpm_worker.so LoadModule mpm_event_module modules/mod_mpm_event.so |
Save the file and exit the text editor.
Step 4: Restarting Apache
To implement the changes, you need to restart the Apache HTTP server. Use the following command:
sudo systemctl restart httpd
Step 5: Verifying the Changes
You can verify if Event MPM is enabled by running the following command:
httpd -V | grep MPM
Output:Server MPM: event
This should now show that the Event MPM is enabled.
Conclusion
With this, you have successfully enabled the Event MPM in Apache on CentOS/RHEL. Event MPM can significantly improve your server’s performance, especially if it serves high-traffic websites. However, it’s also crucial to monitor and tweak your server settings as per your specific use case to ensure optimal performance.
4 Comments
I will thinking to change module prefork to module event/worker. but if any reflect to current project?
How to Check default parameters of prefork worker and event mpm and how to change these.
Hi If I do this Apache fails and will not start till I change it back? (CentOS7)
[root@pnl-server1 ~]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2016-01-13 11:10:50 EST; 3min 19s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 151 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 122 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 122 (code=exited, status=1/FAILURE)
Jan 13 11:09:44 pnl-server1.petenetlive.com systemd[1]: httpd.service failed.
Jan 13 11:10:50 pnl-server1.petenetlive.com systemd[1]: Starting The Apache HTTP Server…
Jan 13 11:10:50 pnl-server1.petenetlive.com httpd[122]: AH00526: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:
Jan 13 11:10:50 pnl-server1.petenetlive.com httpd[122]: Invalid command ‘php_value’, perhaps misspelled or defined by a module not included in the server configuration
Jan 13 11:10:50 pnl-server1.petenetlive.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 13 11:10:50 pnl-server1.petenetlive.com kill[151]: kill: cannot find process “”
Jan 13 11:10:50 pnl-server1.petenetlive.com systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 13 11:10:51 pnl-server1.petenetlive.com systemd[1]: Failed to start The Apache HTTP Server.
Jan 13 11:10:51 pnl-server1.petenetlive.com systemd[1]: Unit httpd.service entered failed state.
Jan 13 11:10:51 pnl-server1.petenetlive.com systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@pnl-server1 ~]# nano /etc/httpd/conf.d/php.conf
[root@pnl-server1 ~]#
[root@pnl-server1 ~]#
[root@pnl-server1 ~]# nano /etc/httpd/conf.modules.d/00-mpm.conf
[root@pnl-server1 ~]# service httpd start
Redirecting to /bin/systemctl start httpd.service
[root@pnl-server1 ~]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2016-01-13 11:16:22 EST; 5s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 151 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Main PID: 710 (httpd)
Status: “Processing requests…”
CGroup: /system.slice/httpd.service
├─710 /usr/sbin/httpd -DFOREGROUND
└─712 /usr/sbin/httpd -DFOREGROUND
I had the same, but when checking the apache config for syntax errors, I got this
# apachectl configtest
AH00526: Syntax error on line 34 of /etc/httpd/conf.d/php.conf:
Invalid command ‘php_value’, perhaps misspelled or defined by a module not included in the server configuration
and the httpd server started up fine, after I’d commented out the 3 lines with that problem config variable
#
# Apache specific PHP configuration options
# those can be override in each configured vhost
#
#php_value session.save_handler “files”
#php_value session.save_path “/var/lib/php/session”
#php_value soap.wsdl_cache_dir “/var/lib/php/wsdlcache”