Linux VPS

Enable HTTP/2 in Apache with mod_http2

Turn on HTTP/2 in Apache 2.4: switch to the event MPM and PHP-FPM, enable mod_http2, set the Protocols directive, check TLS requirements and verify that browsers negotiate h2.

IntermediateLinux VPS3 min read

HTTP/2 lets a browser send many requests over one connection at the same time, compresses headers and removes much of the overhead of HTTP/1.1. Apache supports it through mod_http2. Enabling HTTP/2 in Apache takes a few minutes, but there is one catch: it does not work properly with the prefork MPM.

Before you start

  • Apache 2.4.24 or newer (apachectl -v).
  • HTTPS working: browsers only use HTTP/2 over TLS.
  • Root access. Background on the protocol: HTTP/2 and HTTP/3 explained.

Switch from prefork to event

mod_http2 refuses to serve h2 with prefork (it logs a warning and falls back to HTTP/1.1), because prefork can only handle one request per process. Check your MPM:

apachectl -V | grep -i mpm

If it says prefork, move PHP to PHP-FPM and enable event first. Full steps: Apache MPMs explained. In short, on Ubuntu:

sudo apt install php8.3-fpm
sudo a2dismod php8.3 mpm_prefork
sudo a2enmod mpm_event proxy_fcgi setenvif
sudo a2enconf php8.3-fpm

Enable mod_http2

  • Ubuntu/Debian: sudo a2enmod http2
  • AlmaLinux/Rocky: sudo dnf install mod_http2 (often already installed; check /etc/httpd/conf.modules.d/10-h2.conf).

Set the Protocols directive

Add globally (e.g. /etc/apache2/conf-available/http2.conf, then a2enconf http2) or per vhost:

Protocols h2 http/1.1
  • h2 is HTTP/2 over TLS, negotiated with ALPN during the handshake.
  • http/1.1 stays as the fallback for old clients.
  • You can add h2c (cleartext HTTP/2) for internal backends, but browsers never use it.

Check TLS settings

HTTP/2 blacklists old cipher suites. Use a modern configuration with TLS 1.2 and 1.3 and ECDHE + AES-GCM or ChaCha20 ciphers:

SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLHonorCipherOrder off

More on this: TLS versions and cipher suites.

Restart and verify

  1. sudo apachectl configtest && sudo systemctl restart apache2
  2. From the command line:
    curl -sI --http2 https://example.com/ | head -1
    It should print HTTP/2 200.
  3. In Chrome or Firefox DevTools → Network, show the Protocol column: requests should show h2.
  4. Logs: add %H to your LogFormat to record the protocol per request.

Tuning notes

  • Drop old HTTP/1.1 tricks: domain sharding and heavy file concatenation help less with HTTP/2, since requests are multiplexed.
  • Server push: H2Push is deprecated and browsers have removed support. Use <link rel="preload"> or 103 Early Hints instead (H2EarlyHints on in Apache 2.4.58+).
  • Keep-alive: HTTP/2 connections stay open between page views; event MPM handles this efficiently.
  • HTTP/3: Apache does not serve HTTP/3 natively. Put a CDN in front, or use LiteSpeed, Nginx or Caddy if you need it.

Troubleshooting

  • Still HTTP/1.1: prefork still active, Protocols missing in the HTTPS vhost, or an old OpenSSL without ALPN.
  • Log warning "mpm_prefork ... h2 disabled": switch MPM.
  • ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY: a weak cipher was negotiated. Update the cipher list.

FAQ: HTTP/2 in Apache

Does HTTP/2 make every site faster?

Pages with many assets benefit most. Single-file APIs see little difference.

Do I need to change my website code?

No. HTTP/2 is negotiated by the server and browser; the content is unchanged.

Is HTTP/2 on by default on cPanel hosting?

Yes on MdmHost, where LiteSpeed serves HTTP/2 and HTTP/3.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.