how to enable http2 on centos7

Adam picture Adam · Nov 21, 2016 · Viewed 22.3k times · Source

I have CENTOS7 server, with:

Server version: Apache/2.4.6 (CentOS)

. How can i enable/add HTTP/2 on these Apache ? I'm trying to send http2 requests from the client via Nghttp, but i get an error in the response (recv RST_STREAM frame ) as a result of server which does not supports Http2.

I saw that i have to enable module_http2 in the apache, but i didn't found hot can i do this.

Thanks in Advance.

Answer

Barry Pollard picture Barry Pollard · Nov 21, 2016

HTTP/2 support was only added in Apache 2.4.18 which is not available in the standard CentOS/Red Hat repos. Though as mod_http2 was (and still is at time of writing) being actively worked on you should go with the latest version (2.4.33 at time of writing - though there are further mod_http2 patches available on top of that).

Additionally HTTP/2 requires OpenSSL 1.0.2 or above which means you need CentOS/RHEL 7.4 or above unless you want to install your own version of OpenSSL as well your own version of Apache. Note you need Apache 2.4.26 or above if you want to go further than that and go to OpenSSL 1.1.0.

So you need to download and compile a later Apache (and possibly OpenSSL) from source - or find another repo with these later versions. This does carry some risks - primarily that you lose the easy security patches that repo versions supply. CentOS Apache 2.4.6 actually includes all the latest security patches of later versions (assuming you regularly run "yum update" to update it) - but not the functionality changes like HTTP/2 (hence why they leave version number at 2.4.6).

If you're interested in installing from source then I've a step by step blog post on how to do that here: https://www.tunetheweb.com/performance/http2/