To use mpm_event
and support HTTP/2, you should disable all versions of PHP that rely on mpm_prefork
. Then, you can configure php-fpm
for each version of PHP you want to use.
Steps
Disable all versions of PHP using
mpm_prefork
:Find out which PHP versions are active:
apache2ctl -M | grep php
Then disable them:
sudo a2dismod php7.4 sudo a2dismod php8.0 sudo a2dismod php8.2
Disable
mpm_prefork
and enablempm_event
:Disable
mpm_prefork
:sudo a2dismod mpm_prefork
Enable
mpm_event
:sudo a2enmod mpm_event
Enable
php-fpm
for each version:Install
php-fpm
for each version:sudo apt-get install php7.4-fpm sudo apt-get install php8.0-fpm sudo apt-get install php8.2-fpm
Enable
proxy_fcgi
andsetenvif
:sudo a2enmod proxy_fcgi setenvif
Enable
php-fpm
configurations:sudo a2enconf php7.4-fpm sudo a2enconf php8.0-fpm sudo a2enconf php8.2-fpm
Configure virtual hosts to use
php-fpm
:In each virtual host, replace
SetHandler
with:<FilesMatch \\.php$> SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost/" </FilesMatch>
Change
php7.4
to the corresponding version for each host.Restart Apache:
sudo systemctl restart apache2
Conclusion
Now, your virtual hosts are configured to use php-fpm
and support the HTTP/2 protocol.