3

How to switch MPM Prefork to Event on Apache 2.4, Debian 8? I have already installed php-7 and php-fpm but can not find a complete tutorial on switching MPM Prefork to Event. I tried this but MPM Prefork is still running instead of Event.

2 Answers2

3

I did the following steps one by one:

su
export PATH=$PATH:/sbin
a2dismod php7.1
a2dismod mpm_prefork
a2enmod mpm_event
a2enmod proxy_fcgi
a2enconf php7.1-fpm
systemctl restart apache2

If php7.1-fpm is not installed, you can install it before the mentioned steps using apt-get install php7.1-fpm or you can check if it is installed using dpkg -l {package_name}

finally, you can make sure of what you did using: apachectl -V

s.abbaasi
  • 952
  • 6
  • 14
  • I guess that works, but why not just use `sudo` (safer & no path should be needed): `sudo a2dismod phpX.X mpm_prefork` && `sudo a2enmod mpm_event proxy proxy_fcgi` && `sudo a2enconf phpX.X-fpm` && `sudo systemctl restart apache2` <- sub your php version. See https://wiki.debian.org/sudo – B. Shea Nov 21 '22 at 16:36
  • @B.Shea Yes. It is also true. I wrote that just for summarization. – s.abbaasi Nov 27 '22 at 17:40
  • 1
    NP. BTW you have `proxy_fcgi`, but you need to add the `proxy` module since it's a dependency: See last comment by me -> `sudo a2enmod mpm_event proxy proxy_fcgi` - see deps for https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html - "This module requires the service of mod_proxy." – B. Shea Nov 27 '22 at 19:33
-1

Do, a2query -M to check current mpm_ worker(either prefork, event or worker). Suppose its currently prefork.

So, if you want to switch to mpm_event . Go to /etc/apache2/mods-enabled and do ls -la there will be symbolic links of mpm_prefork.conf and mpm_prefork.load .

THEN rename the mpm_prefork links to anything else (could be mpm_prefork2.conf and mpm_prefork2.load).

To Rename (run these commands) : cd /etc/apache2/mods-enabled and

mv mpm_prefork.conf mpm_prefork2.conf &

mv mpm_prefork.load mpm_prefork2.load

And then create new symbolic links mpm_event.conf and mpm_event.load from /mods-available to /mods-enabled like this :

  1. sudo ln -s /etc/apache2/mods-available/mpm_event.load /etc/apache2/mods-enabled/mpm_event.load
  2. sudo ln -s /etc/apache2/mods-available/mpm_event.conf /etc/apache2/mods-enabled/mpm_event.conf
  3. And restart apache. sudo service apache2 restart.

Now, do a2query -M it will display event now. You have successfully switched mpm_prefork to mpm_event

Maverick1604
  • 331
  • 3
  • 14
  • 4
    For Debian, it is better if you don not touch those `.conf` files directly and use the `a2enmod` and `a2dismod` commands. As a bonus, you can be notified about potential misconfigurations: for example that the module `php7.x` is not compatible with `mpm_event`. Therefore you would disable it first with `a2dismod` and then: 1. `sudo a2dismod mpm_prefork` 2. `sudo a2enmod mpm_event` – user2658323 Mar 14 '19 at 08:51