More Than Just Web Design | INTERNET ENGINEERING | APPLICATION | DESIGN

Compiing PHP 5.6.40 on Ubuntu 18.04

Posted: 06/07/19

Compiling PHP 5.6.40 on Ubuntu 18.04 isn't as straight forward as 16.04. In particular there are issues with CURL and OpenSSL

CURL libraries are not found

The fix here is a simple symbolic link:

sudo ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl

OpenSSL causes compile errors

The issue here appears to be that the 1.1.1 release of OpenSSL is incompatible with the PHP 5.6.40 source code. The solution is to build an earlier version and compile against that.

cd /usr/src
wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz
tar xfz openssl-1.0.2s.tar.gz
# Install in to  /opt/usr/local/openssl so it does not conflict with anything else
# Compile it as dynamic library
./config -fPIC shared --prefix=/opt/usr/local --openssldir=/opt/usr/local/openssl
make
make test
make install

Now we export the configuration for the PHP configure script to pick up:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Now we build PHP:

cd /usr/src/php-5.6.40
 
./configure \
--with-openssl=/opt/usr/local \
--prefix=/opt/php/5.6 \
--sysconfdir=/etc/php/5.6 \
--with-fpm-systemd \
--with-config-file-path=/etc/php/5.6 \
--with-config-file-scan-dir=/etc/php/5.6/php.d \
--disable-ipv6 \
--with-jpeg-dir=/usr/include \
--with-mysql \
--with-mysqli \
--enable-fpm \
--with-gd \
--enable-bcmath \
--enable-calendar \
--enable-dba \
--with-curl \
--with-enchant \
--with-gettext \
--enable-intl \
--enable-mbstring \
--with-mcrypt \
--with-pcre-regex \
--with-pspell \
--with-readline \
--with-pdo-mysql \
--enable-exif \
--enable-ftp \
--with-mhash \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--enable-zip \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-bz2 \
--with-zlib \
--enable-gd-native-ttf \
--with-xpm-dir=/usr/include/X11 \
--with-freetype-dir=/usr/include/freetype2
 
make
make test
make install

Depending on your enviroment, you may need to add:

openssl.capath=/etc/ssl/certs

to your php.ini so that SSL doesn't throw a hissy fit over certificates it cannot validate.