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)

6 Answers 6


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
  • 4
    You need to be there... Not here.. there... on the top of the Answers list. Aug 13, 2016 at 9:47
  • 2
    This should be the accepted answer! Don't forget to restart apache after doing this: sudo service apache2 restart
    – Reeno
    Aug 22, 2016 at 16:11
  • 5
    How 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. Mar 6, 2017 at 8:05
  • 3
    @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?
    – nicbou
    Oct 1, 2017 at 14:08
  • 1
    @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.
    – nicbou
    Oct 2, 2017 at 11:02

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
  • This is the correct answer!
    – DrSvanHay
    Aug 25, 2018 at 16:42

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.

  • 5
    Can'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 see php5 diable it.
    – pferrel
    Mar 19, 2015 at 16:41
  • run httpd.exe -M on Windows to see all running modules
    – GChuf
    May 4, 2020 at 13:34

For me following fully work on debian:

  1. Disable prefork, enable event: a2dismod mpm_prefork && a2enmod mpm_event
  2. remove mod-php5: aptitude remove libapache2-mod-php5
  3. Be aware that you have each php_ Option in your VHost encapsulate by <IfModule mod_php5.c></IfModule>, otherwise apache won't restart
  4. do service apache2 restart

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
  • NO, 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.
    – suther
    Oct 10, 2017 at 10:26

the php5 module needs the prefork mpm, and to disable prefork, one has to disable php5.

under debian, i did the following, as root:

disable the prefork mpm

a2dismod mpm_prefork

enable the event mpm, or whatever mpm you might prefer. note i found event mpm was not recommended for apache 2.2 or earlier

a2enmod mpm_event

to disable the php5 module load, but without uninstallation.

a2dismod php5

to test the overall correctness of the resulting apache config. errors would need to be coped with as per the answer of @sulther above.

apache2ctl -t

restart apache

systemctl restart apache2

in case php is still needed, a threadsafe version should be installed. see: https://www.digitalocean.com/community/tutorials/how-to-configure-apache-http-with-mpm-event-and-php-fpm-on-freebsd-12-0

good luck

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .