How to enable event MPM Apache 2.4 on Ubuntu 14.04 with thread safe PHP?
Solution 1
To disable event MPM
, you can do sudo a2dismod mpm_event
and after that to enable prefork
, you should do sudo a2enmod mpm_prefork
.
Finally restart apache:
sudo service apache2 restart
Solution 2
This worked for me.
First check if you have this package installed:
dpkg -l | grep libapache2-mod-php5
If you have it just remove it:
apt-get remove libapache2-mod-php5
Solution 3
You can install multiple ways for Apache to communicate with PHP in parallel. Maybe you have (still) the old mod_php installed, additionally to fastcgi/php-fpm.
You can see which modules your Apache has loaded at runtime with
apache2ctl -M
If needed, use sudo
to get root privileges. If you see php5_module (shared)
among the modules your Apache is currently using, the old mod_php is still installed and blocks you from using mpm_worker
or mpm_event
.
Solution 4
For me following fully work on debian:
- Disable prefork, enable event:
a2dismod mpm_prefork && a2enmod mpm_event
- remove mod-php5:
aptitude remove libapache2-mod-php5
- Be aware that you have each
php_
Option in your VHost encapsulate by<IfModule mod_php5.c></IfModule>
, otherwise apache won't restart - do
service apache2 restart
Solution 5
Look for the following in the Load Modules sections of your apache configuration file :
LoadModule mpm_event_module modules/mod_mpm_event.so
And replace it with the following module :
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
Related videos on Youtube
Towerman
Updated on September 18, 2022Comments
-
Towerman over 1 year
I upgraded to Ubuntu Server 14.04 expecting the default apache installation would use the new event MPM, but instead I find the old memory-eating prefork.
I've successfully set up event MPM in Arch Linux, but I'm failing to do so on Ubuntu. I keep getting:
Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP
I' ve already installed
php-fpm
, and configured apache2 to use it, but since the config files for apache2 are different on Ubuntu, i'm not quite sure whether i'm doing it on the right place.Any idea on how to make PHP thread safe so I can use apache2 event-mpm? (without having to manually recompile php, of course)
-
pferrel about 9 yearsCan't run that to get mods if the server is not starting, try
sudo a2dismod
then hit the tab character twice to see a list if mods that can be disabled. If you seephp5
diable it. -
Karma over 7 yearsYou need to be there... Not here.. there... on the top of the Answers list.
-
Reeno over 7 yearsThis should be the accepted answer! Don't forget to restart apache after doing this:
sudo service apache2 restart
-
Eric over 7 yearssaved me after an hour of bulls*&t answers! You rock!
-
Craig Tullis about 7 yearsHow does this answer the question of how to enable MPM, like the OP asked? You're explaining how to do the opposite of what the OP asked for.
-
Mehraban about 7 years@Craig take a look at this. There are multiple choices to get Multi Processing in apache web server.
-
nicbou over 6 years@Mehraban, OP asked word for word "How to enable event MPM?", and your answer is "Just disable event MPM". How is this an acceptable answer?
-
Mehraban over 6 years@NicolasBouliane check the link I suggested to Craig in comments. The real problem here is getting multi processing in apache web server not the MPM itself.
-
nicbou over 6 years@Mehraban That's not the question that was asked though, so all the traffic coming here from Google is getting told "the best way to do X is not do to X". If I ask how to make chocolate cookies, I expect a chocolate cookie recipe.
-
Mehraban over 6 years@NicolasBouliane if this is the accepted answer, doesn't it mean that "it is what OP was after"? I think you should talk to OP to rephrase the question.
-
suther over 6 yearsNO, don't do this! Apache is build modular, so you don't have to change any LoadModule-Lines into your configs. Only do
a2dismod mpm_prefork && a2enmod mpm_event
. Then restart your apache, and you're done. -
Towerman over 6 yearsI followed this answer and continued to use the prefork approach rather than event mpm. But @NicolasBouliane has a valid point, I could rephrase the question or if someone else has another (valid) way to switch to MPM, just let me know. I can't test since I don't have ubuntu 14.04, I switched to nginx on top of docker on top of ubuntu 16.04
-
DrSvanHay over 5 yearsThis is the correct answer!
-
GChuf almost 4 yearsrun
httpd.exe -M
on Windows to see all running modules