Getting http/2 and php in mod_php to work
Here is how I got the mod_php to work with http/2:
Following scrupul0us's experience, (php compilation errors, versions indiscrepancies in phpinfo() and instability), I tried to compile the new version of openssl as a shared library (and to use that shared library only in apache and mod_php)
Here are the changes from the original procedure:
Building the openssl 1.0.2, and creating a shared library:
Using the command
Code:
./config --openssldir=/usr/local/lib_http2 zlib-dynamic shared
Note that this command is different, then the suggested config command.
It includes the "shared"" argument and it does not have the flags -no-ssl2 and -no-ssl3.
(see openssl documentation
https://wiki.openssl.org/index.php/Compilation_and_Installation),
These protocols (sslv2 and 3) should be removed, but it seems that mod_ssl requires at least sslv3 and I did have the instability issue as scrupul0us described without these flags (but it requires further testing, I haven't tested it it with -no-ssl2 only).
Once the compilation of openssl 1.0.2 completed, the created shared libraries has been copied to /usr/local/lib
Code:
cp /usr/local/lib_http2/lib/libcrypto.so.1.0.0 /usr/local/lib
cp /usr/local/lib_http2/lib/libssl.so.1.0.0 /usr/local/lib
Now the custom configuration files for compiling apache at the locations, should be created (or modified)
custom/ap/configure.apache
and
custom/ap/configure.php55 (your version might vary)
Replace in custom/ap/configure.apache the phrase
with:
Code:
"--enable-http2" \
"--with-ssl=/usr/local/lib_http2" \
(The flag --enable-ssl-staticlib-deps as used in the original guide has been removed, since we are using the shared libraries and not static libraries)
and in the php custom configuration:
replace the original
with the following:
Code:
--with-openssl=/usr/local/lib_http2 \
--with-openssl-dir=/usr/local/lib_http2 \
(I am not sure whether the second line is required --with-openssl-dir=/usr/local/lib_http2, a line --with-open-ssl-dir does not exist in the original confiure.apache in custombuild)
now used custombuild to build php and apache
./build php
./build apache
(and doing all the other steps in the original guide, except with the changes described here)
Now there is no discrepancy in phpinfo() output:
openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.2f 28 Jan 2016
OpenSSL Header Version OpenSSL 1.0.2f 28 Jan 2016
Without copying the .so.1.0.0 files to /usr/local/lib, an error would appear that says that libssl.so.1.0.1 cannot be found (this can be resolved using other ways such as executing setting the environment variable PHP_RPATHS to include the new library path /usr/local/lib_http2/lib before executing custombuild's./build php).
(it seems that copying these shared library files to /usr/local/lib does not affect the system's openssl e.g. some other package will use this new openssl instead of the old but stable operaing system openssl)