Hypertext Transfer Protocol Version 2 (HTTP2), defined in RFC 7540 improves website performance and enables a more efficient use of network resources. Unlike its predecessor, HTTP/1.1, HTTP/2 can handle heavy loads of resources such as images, fonts, scripts, and stylesheets which result in better load speeds. It reduces latency by introducing header field compression and enables multiplexing, which allows the client and server to process multiple concurrent requests over the same connection.
During a default install on Debian, Apache is configured with mpm_prefork
. This will not work with HTTP/2. You need to use either mpm_event
or mpm_worker
. For our example, we used mpm_event
.
-
Stop apache
apachectl stop
-
Install php7.3-fpm
apt-get install php7.1-fpm #
Install the php-fpm from your PHP repository. This package name depends on the vendor.
-
Enable module for fast cgi
a2enmod proxy_fcgi setenvif
-
Enable the php-fpm configuration
a2enconf php7.3-fpm # Again, this depends on your PHP vendor.
-
Disable mod_php
a2dismod php7.3 #
This disables mod_php.
-
Disable mpm_prefork
a2dismod mpm_prefork #
This disables the prefork MPM. Only one MPM can run at a time.
-
Enable mpm_event
a2enmod mpm_event #
Enable event MPM. You could also enable mpm_worker.
-
Enable the HTTP/2 module
a2enmod http2
-
Restart Apache
apachectl start
- RFC 7540 - Hypertext Transfer Protocol Version 2 (HTTP/2)
- HTTP/2 site - IETF HTTP Working Group
- Introduction to HTTP/2 - Google
Note: Developed on a server running Debian 10.2 and Apache 2.4.38.
This documentation is part of the Internet Society's Open Standards Everywhere project. To find the most recent version or to provide feedback, please visit https://github.com/InternetSociety/ose-documentation