Requirements
- Apache 2.4.17 or later with the
mod_http2module. All current distributions ship it. - HTTPS with TLS 1.2 or 1.3 and modern cipher suites. Browsers only speak HTTP/2 encrypted. A matching configuration is in the article set up SSL/TLS in Apache.
- MPM event or worker. With the old
prefork, Apache no longer offers HTTP/2 at all since 2.4.27. This is the most common reason when “nothing happens”.
Switch from prefork to event
prefork is usually only active because mod_php requires it. The solution is PHP-FPM: PHP runs as its own service and Apache passes requests on. On Debian and Ubuntu (adjust the PHP version):
sudo apt install php8.3-fpm sudo a2dismod php8.3 mpm_prefork sudo a2enmod mpm_event proxy_fcgi setenvif http2 sudo a2enconf php8.3-fpm sudo systemctl restart apache2
On RHEL, Rocky and Alma event is already the default. Check the model with apachectl -V | grep -i mpm.
Turn on HTTP/2
One line, globally in the main configuration or in the respective <VirtualHost *:443>:
Protocols h2 http/1.1 # optional: HTTP/2 without TLS (h2c), only for internal services behind a proxy # Protocols h2 h2c http/1.1 # no browser uses server push any more, Chrome removed it H2Push off
Then apachectl configtest and systemctl reload apache2.
Test
curl -sI --http2 https://www.example.com -o /dev/null -w '%{http_version}\n'
# output 2 = HTTP/2 active
Without a command line, use the HTTP/2 & HTTP/3 check. If it still says 1.1, check the MPM, whether mod_http2 is loaded (apachectl -M | grep http2) and whether the Protocols line is in the right vhost.
And HTTP/3?
HTTP/3 runs over QUIC on UDP. Apache httpd still does not support it, not even with add-on modules in the official package. If you want HTTP/3, put something in front that speaks QUIC:
- nginx as a reverse proxy in front of Apache, with HTTP/3 to the outside. The setup is in the article enable HTTP/3 in nginx.
- Caddy speaks HTTP/3 without extra configuration and obtains certificates itself.
- HAProxy 2.6 or later with a QUIC-capable TLS library.
- A CDN such as Cloudflare or Bunny that speaks HTTP/3 to visitors and HTTP/2 to your Apache.
For most sites HTTP/2 already brings most of the gain. HTTP/3 helps mainly on mobile and changing networks.
FAQ
Do I need HTTP/2 between the proxy and Apache too?
No. If nginx, HAProxy or a CDN in front terminate TLS, HTTP/1.1 internally is enough. The gain happens on the way to the visitor.
Does .htaccess still work after switching to PHP-FPM?
Yes. .htaccess is an Apache feature, not mod_php. Only php_value lines in .htaccess no longer work with PHP-FPM; they belong in the pool configuration or a .user.ini.
How do I enable HTTP/2 at my web host?
Not yourself. On shared hosting the host decides. Most have offered HTTP/2 for a long time; the check shows you.