I had a real battle getting HTTP/2 to work on my new AMI2 Lamp webserver this week. The Apache http2 module was installed but it didn’t work alongside mod_mpm_prefork, so I needed to switch to the mod_mpm_event module. However this wouldn’t start unless the server was using php-fpm. So what seemed like a simple task of just upgrading my HTTP requests to HTTP/2, turned into a little bit of work and searching on Google didn’t offer much assistance as everyone else seemed to be using a Debian based linux which had a2enmod available.

The article is really just in note form for my own reference, but I hope it points you in the right direction if you’re having problems getting it all to work.


Make sure php-fpm is installed. PHP FPM is an article in it’s own right, but the following might be useful:

> sudo yum install -y php-fpm


Once it’s installed, make sure php-fpm is running as a service:

> sudo systemctl start php-fpm


Make sure it starts on reboot.

> sudo systemctl enable php-fpm


Make sure it’s listening on

> sudo vi /etc/php-fpm.d/www.conf


Edit the config file above (assuming that’s where it is on your computer) and change the following:

;listen = /run/php-fpm/www.sock
listen =



You can confirm if Apache is processing requests using PHP-FPM via the phpinfo() output.



Make sure Apache is configured to use event MPM.

> sudo vi /etc/httpd/conf.modules.d/00-mpm.conf


#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule mpm_event_module modules/mod_mpm_event.so

Make sure PHP is processing with php-fpm

> sudo vi /etc/httpd/conf.d/php.conf


ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://$1DirectoryIndex /index.php index.php#<FilesMatch .(php|phar)$>
# SetHandler application/x-httpd-php


UPDATE 19/5/2023: Alternatively you can leave it as listen = /run/php-fpm/www.sock in /etc/php-fpm.d/www.conf but if that’s the case omit adding ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://$1 to /etc/httpd/conf.d/php.conf as well.

Important bit:
Make sure mod_php is not installed.

> sudo yum remove mod_php -y


This was the important one for me. The error message I was getting before doing the above was ‘Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.’.



> sudo vi /etc/httpd/conf.d/ssl.conf


# enable HTTP/2, if available
Protocols h2 h2c http/1.1
H2Direct on


Useful commands:

> sudo service php-fpm reload
> sudo service php-fpm restart
> sudo service httpd restart


Useful resources: