Saturday, 20 April 2013

Switching Apache MPM Prefork to Apache MPM Worker simply

The drawback to doing everything with processes is that Apache prefork can be a bit of a memory hog, especially under load. Another precompiled flavor of Apache can be installed as an alternative:Apache MPM worker. "Worker" differs from "prefork" in that worker's processes are multithreaded, giving them the ability to service more requests with fewer system resources. This can translate into faster pages served with less RAM and CPU. However, because some Apache modules don't necessarily work well when run under multithreaded Apache, you have to specifically select this version to install on Ubuntu and on other GNU/Linux distros with package management.
Apache comes by default as mpm-prefork.
But you will want to instead use mpm-worker, as it will use less memory and be more efficient.
To use the “worker” MPM with PHP, do the following:
Step 1. Stop the apache2 daemon
sudo /etc/init.d/apache2 stop
Step 2.  Uninstall apache2-mpm-prefork
sudo aptitude remove apache2-mpm-prefork
Step 3.  Install apache2-mpm-worker and apache2-threaded-dev
sudo aptitude install apache2-mpm-worker apache2-threaded-dev
Step 4. Enable CGI and mod_actions (may already be enabled)
sudo a2enmod cgid2sudo a2enmod actions
Step 5.  Create a file in /etc/apache2/conf.d with the following content (I called mine php5-cgi.conf):
<IfModule mod_actions.c>2 Action application/x-httpd-php /cgi-bin/php53</IfModule>
Step 6.  Start the apache2 daemon
sudo /etc/init.d/apache2 start

Another way is this way by PCJonathan

No comments:

Post a Comment