Hi,
I came across some really excellent tutorials on DigitalOcean on how to install LAMP on Ubuntu, but none of them mention anything about choosing a specific Apache MPM (Multi Processing Module).
The latest versions of Apache offer the Event MPM, which is the Apache’s only hope and fighting chance for good benchmarks against NGINX. The Ubuntu 14.04 LAMP image is configured with the oldest Prefork MPM, which is also the clumsiest and RAM hungriest of all Apache MPMs.
It would be great to see a tutorial on how to configure Apache in a LAMP setup to use the Event MPM with - or without - PHP-FPM.
Much appreciated!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Assuming that you’re starting with a basic LAMP stack, to get Event MPM and PHP-FPM up and running on Ubuntu 14.04 first install these packages:
sudo apt-get install libapache2-mod-fastcgi php5-fpm apache2-mpm-event
Then create the file /etc/apache2/conf-available/php5-fpm.conf with the contents:
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule>
Then enable the new mods and config:
sudo a2enmod actions fastcgi alias
sudo a2dismod mpm_prefork php5
sudo a2enconf php5-fpm
sudo a2enmod mpm_event
sudo service apache2 restart
You should be all set to go!
Hey, what would be the recommended values for the Apache with Event MPM settings, and where is the configuration file to put them in? I didn’t find them (even the defaults) specified in the main apache2.conf.
I know these settings depend mostly on the RAM available to the server, so if I get a recommendation for one droplet size, then I can scale accordingly for other sizes. Here is an example I found online:
<IfModule event.c>
StartServers 3
MinSpareThreads 75
MaxSpareThreads 250
ThreadsPerChild 25
MaxClients 400 // MaxRequestWorkers
MaxRequestsPerChild 0 // MaxConnectionsPerChild
</IfModule>
As it turns out, PHP-FPM has its own equivalent settings, like pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers, pm.max_requests, etc. Are these use together with the Apache settings, i.e. for dynamic content, or they complement/supercede them? Here’s an example for these (I understand they are specified in the FPM’s php.ini):
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 0
Thanks in advance!
Yuri
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.