Skip to content

Enabling HTTP/2 on a cPanel server with Apache

How to enable HTTP/2 on cPanel's Apache build via EasyApache 4's mod_http2, what changes for clients, and the keep-alive and MPM implications you need to handle.

HTTP/2 is a free latency win for any cPanel server with TLS already in place — same TLS handshake, multiplexed streams, header compression, server push for clients that support it. The cPanel toggle is two clicks. The supporting changes — the MPM choice, the keep-alive settings, and the per-vhost confirmation — are what most operators miss when they wonder why HTTP/2 is “enabled” but every connection is still negotiating HTTP/1.1.

What’s happening

mod_http2 is an Apache module that handles HTTP/2 frames on the same socket as HTTP/1.1, after ALPN negotiation during the TLS handshake. The client lists the protocols it supports; the server picks. If mod_http2 is loaded and Protocols h2 http/1.1 is set on the vhost, modern clients land on HTTP/2. HTTP/2 only works over TLS in practice (browser implementations require it), and it does not work under the prefork MPM with mod_php — the worker-per-connection model breaks the multiplexing assumption.

How to verify

Check what is loaded and what the vhost is offering:

apachectl -M | grep http2
rpm -qa | grep ea-apache24-mod-http2
apachectl -V | grep MPM
curl -v --http2 -I https://example.com/ 2>&1 | grep -E "^(< HTTP|ALPN|using HTTP)"
openssl s_client -alpn h2 -connect example.com:443 < /dev/null 2>&1 | grep ALPN

The curl line shows whether HTTP/2 actually upgraded. The openssl line shows what the server offers via ALPN.

The fix

  1. Confirm the MPM is event (or worker), not prefork. If prefork, swap to event first — see the dedicated MPM-switch article.
  2. Install mod_http2 via EasyApache 4: WHM > EasyApache 4 > Customize > Apache Modules > check mod_http2 > Provision. Or directly: yum install -y ea-apache24-mod-http2 && /scripts/rebuildhttpdconf && apachectl -t && apachectl graceful.
  3. Enable HTTP/2 protocol negotiation. WHM > Apache Configuration > Include Editor > Pre Main Include > add:
    Protocols h2 http/1.1
    ProtocolsHonorOrder On
    H2WindowSize 65535
    This sets the protocol for every TLS-enabled vhost.
  4. Confirm with curl -v --http2 -I https://example.com/ — the response should contain using HTTP/2 and the response status line should start with HTTP/2.
  5. Verify HTTP/1.1 still works for legacy clients: curl -v --http1.1 -I https://example.com/ should succeed.
  6. Tune keep-alive. HTTP/2 multiplexes, so KeepAliveTimeout 5 is too aggressive — the browser will reconnect mid-page-load. Bump to 30 in WHM > Apache Configuration > Global Configuration.
  7. Save the EA4 profile so the mod_http2 package is captured.

For environments where HTTP/2 (and eventually HTTP/3) is part of the baseline, Stack Harbor sets these defaults during onboarding under cPanel server management.