HTTP/2 on CentOS 7 on Apache with PHP7

apache-2.4centos7http2php7

After some research I cannot find answer for:
How to update Apache/httpd to newest version to use HTTP/2 protocol on my VPS.
I'm using PHP7 & my server based on Apache – CentOS 7.

No package updates on CentOS defaults repo.

[root@vps270238 ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov 19 2015 21:43:13

I really want to keep my actual settings and Virtual Hosts.

Best Answer

You need Apache 2.4.18 or higher to enable HTTP/2, though some recommend a minimum of Apache 2.4.23 as lots of changes in mod_http2 since then (discussed further below). This also requires some 3rd party software (nghttp2 and a recent version of openssl)

The default repos from Centos are based on Red Hat which prioritises stability rather than latest features. So they often lag behind in versions (though are kept up to date with security patches - even though they leave the version number the same for this).

Additionally the mod_http2 module is still being changed a lot (almost daily if you look at its releases!), so is fairly cutting edge still - though not had any stability issues in months I've been running it.

For that reason, I personally think the best way to use http/2 on Apache is to compile the latest version from source. This is not without its risks of course. For a start you lose protection of the easy to update security patches mentioned above so may have to upgrade more frequently to stay on top of those (no bad thing in my opinion). Additionally you should verify source code before installing it (especially for an application such as Apache which runs, at least initially, as root). So it's not a decision to be taken lightly.

Saying that, if you wish to proceed, installing from source code is not as difficult as that sounds. I've a blog post on how to do it and also use Centos. I don't use PHP so not sure if you need any extra compile options for that.

Note also that by default Apache will install into /usr/local/apache2. This is good as it allows you to keep your original install (incase you need to roll back) but does mean you need to copy any config into /usr/local/apache2/conf, stop the old Apache (including in any startup scripts), and restart the new Apache from the new location.

Related Topic