My question is not about finding out if a server supports HTTP/2 (they both do) but how to make sure PHP is utilizing HTTP/2 with the correct cURL settings for the most current PHP version in CentOS (built from Remi's repository). My own answer addresses some oddities concerning this.
I've setup my CentOS 7 server to support HTTP/2 with the help of this fine guide: Setting up HTTP/2 on your web server
So I've got the latest releases, compiled and installed them and all is working fine. Pages are served with HTTP/2 headers, exactly as they should.
Now I'd like to utilize HTTP/2 functionality in my PHP scripts. Mainly by doing cURL calls in HTTP/2 fashion. I found out I needed to upgrade libcurl
and build and compile it with specific HTTP/2 support. With some setbacks, I got it to work.
So curl -V
tells me:
curl 7.55.0-DEV (x86_64-unknown-linux-gnu) libcurl/7.55.0-DEV OpenSSL/1.1.0f zlib/1.2.7 nghttp2/1.23.1
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy
Great!
And phpinfo()
gives me the same version (7.55.0-DEV
) in conjunction with the newly installed OpenSSL, which is:
OpenSSL 1.1.0f 25 May 2017
And Apache, BTW:
Server version: Apache/2.4.26 (Unix)
Server built: Jul 7 2017 09:47:22
However, when I write a simple PHP script with a cURL call and the CURLOPT_HTTP_VERSION
option set to CURL_HTTP_VERSION_2_0
, as outlined in this example: https://stackoverflow.com/a/37146586/1005334, it tells me the server does not have HTTP/2 support...
How can this be?
One thing I noticed, is the bit about the OpenSSL module in phpinfo()
still mentions my old OpenSSL version (OpenSSL 1.0.1e-fips), although the OpenSSL-version mentioned with the cURL module states OpenSSL 1.1.0f.
I've installed PHP 7.1 (it currently stands at version 7.1.7) from Remi's repository, could it be it is built against an older OpenSSL version so it will not work with my newer one? I also read support in PHP 7 for HTTP/2 is not quite apparent, but I imagine it shouldn't be a problem, right?
Or is OpenSSL not the problem and should I look elsewhere, perhaps compiling PHP from source with some intended flags?