While preparing a new development web server, my plan was to set a number of versions of PHP and have them served up as PHP-FPM instances to be used on Apache 2.4 . Each VirtualHost would be driven via a macro according to the type of website required - in this case, Drupal and Wordpress websites. Parameters are passed to each macro as to the domain, hosted directory and PHP version used.
Everything worked smoothly with the PHP 7.1 and PHP 7.2 installs. It's only when I attempted to install PHP 5.6 did I start to run into problems.
Problem 1 : OpenSSL & Curl
At the time of writing, PHP 5.6.38 configuration file specifically support the following versions of OpenSSL and Curl :
OpenSSL : >= 0.9.6 & < 1.1.0*
Curl : >= 7.10.5
However, when you build PHP 5.6.38 with the latest version of OpenSSL (v1.1.1 FIPS), PHP fails with the following message :
/data/src/php-5.6.38/ext/openssl/openssl.c:664:4: warning: ‘ASN1_STRING_data’ is deprecated [-Wdeprecated-declarations] to_add = ASN1_STRING_data(str); ^~~~~~ In file included from /usr/include/openssl/opensslconf.h:42, from /usr/include/openssl/evp.h:13, from /data/src/php-5.6.38/ext/openssl/openssl.c:44: /usr/include/openssl/asn1.h:554:1: note: declared here DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x)) ^~~~~~~~~~~~~~~~~~
* It turns out that ever since OpenSSL 1.1.0 was released, any builds of PHP 5.6 that included OpenSSL, PHP 5.6 breaks with this error. Several attempts have been made to bring PHP 5.6 up to spec with the latest release of OpenSSL. However in general, PHP 5.6 will officially become unsupported on 1st January 2019. So if you haven't already made plans to transition your websites to at least PHP 7.2, you should do now.
To work around this issue, create a localized build directory and install a version of OpenSSL from source. Here is an example :
mkdir ~/src cd ~/src wget http://www.openssl.org/source/openssl-1.0.0g.tar.gz tar -xzf openssl-1.0.0g.tar.gz cd openssl-1.0.0g ./Configure --prefix=$BUILDDIR linux-x86_64 make make install
Then, in your PHP build configuration, add '--openssl-dir=$BUILDDIR', substituting $BUILDDIR with your local OpenSSL build directory in each instance.
Problem 2 : IMAP extension
When you attempt to build PHP 5.6 with the '--with-imap' & '--with-imap-ssl' configured, PHP 5.6 crashes trying to build PHAR with the following error :
/bin/sh: line 1: 5769 Segmentation fault (core dumped) ` if test -x "/data/src/php-5.6.38/sapi/cli/php"; then /data/src/php-5.6.38/build/shtool echo -n -- "/data/src/php-5.6.38/sapi/cli/php -n"; if test "x" != "x"; then /data/src/php-5.6.38/build/shtool echo -n -- " -d extension_dir=/data/src/php-5.6.38/modules"; for i in bz2 zlib phar; do if test -f "/data/src/php-5.6.38/modules/$i.la"; then . /data/src/php-5.6.38/modules/$i.la; /data/src/php-5.6.38/build/shtool echo -n -- " -d extension=$dlname"; fi; done; fi; else /data/src/php-5.6.38/build/shtool echo -n -- "/data/src/php-5.6.38/sapi/cli/php"; fi;` -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 -d 'safe_mode=0' /data/src/php-5.6.38/ext/phar/build_precommand.php > ext/phar/phar.php make: *** [Makefile:380: ext/phar/phar.php] Error 139
However, when you take those same parameters out, PHP 5.6 builds successfully.
The main problem with the IMAP extension, is that the main libc-client that comes distributed with Linux, has baked-in OpenSSL support. That presents a problem if you want to enable IMAP with SSL support on a PHP 5.6 installation. In order to do this, you will need to :
1) get the source code to the libc-client distribution,
2) build your custom libc-client distribution with the compatible OpenSSL distribution you built earlier, and
3) build your PHP 5.6 installation pointing to your customized libc-client .
At this point in time, I have disabled IMAP on my PHP 5.6 installation, as I don't have any immediate need to use IMAP. However, if anyone has been able to successfully make a customised libc-client distribution with their PHP 5.6 installation, I'll make reference to your solution in a follow-up post.