Setting New PHP Development with Apricity OS & VirtualBox : Part 3 – Install PHP 5.2, 5.3, 5.4, 5.5, 5.6 and 7.0 on single Ubuntu Server 14.04 LTS 32 bit

The application sholud be work on PHP 5 is no longer relevant term for my team. Client use more precision term like PHP 5.2.17, PHP 5.3.3 etc. Its insane to support checking all those claim. The only ‘fair’ play assumption is testing it with more common version. Like PHP 5.2 I decide to use latest version of 5.2 family like 5.2.17.

In this post I try to retry available post that already use same approach but using Ubuntu Server 16.04 LTS that use 64 bit architecture while I use 32 bit Ubuntu 14.04 server for this case.

The Plan

List of Supported PHP version in this post including from  museum are :

5.2 -> 5.2.17

5.3 -> 5.3.29

5.4 -> 5.4.33

5.5 -> 5.5.34

5.6 -> 5.6.20

7.0 -> 7.0.5

Those PHP version will be install in single VM that tun Ubuntu 14.04 server with memory 1GB. In case the memory not fit the process then I can add it easily 🙂

Execution

Install base package and friends

sudo apt-get install -y nginx git autoconf lynx wget build-essential libxml2-dev libssl-dev libbz2-dev libcurl4-openssl-dev  libpng12-dev libfreetype6-dev libxpm-dev libmcrypt-dev libmhash-dev libmysqlclient-dev libjpeg62-dev freetds-dev libjson-c-dev re2c

Setting Local Environment on Ubuntu 14.04 Server

sudo nano /etc/environment

Add these lines :

LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8

save.

Download all PHP source

.tar.bz2 from us1 mirror and php museum :

sudo mkdir /opt/source

cd /opt/source

sudo wget -c http://museum.php.net/php5/php-5.2.17.tar.bz2
sudo wget -c http://museum.php.net/php5/php-5.3.29.tar.bz2
sudo wget -c http://museum.php.net/php5/php-5.4.33.tar.bz2
sudo wget -c http://us1.php.net/distributions/php-5.5.34.tar.bz2
sudo wget -c http://us1.php.net/distributions/php-5.6.20.tar.bz2
sudo wget -c http://us1.php.net/distributions/php-7.0.5.tar.bz2

Extract PHP Source

sudo tar xvjf php-5.2.17.tar.bz2
sudo tar xvjf php-5.3.29.tar.bz2
sudo tar xvjf php-5.4.33.tar.bz2
sudo tar xvjf php-5.5.34.tar.bz2
sudo tar xvjf php-5.6.20.tar.bz2
sudo tar xvjf php-7.0.5.tar.bz2

Patch and Build PHP 5.2.17 on Ubuntu Server 14.04 32 bit Server

Patch PHP 5.2.17

SimpleXML

cd /opt/source/php-5.2.17

sudo curl -o php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt

sudo patch -p0 -b < php-5.2.17.patch

PHP-FPM

sudo wget -c http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz

sudo gunzip php-5.2.17-fpm-0.5.14.diff.gz

sudo patch -p1 < php-5.2.17-fpm-0.5.14.diff

OpenSSL

sudo wget -c -t 3 -O ./debian_patches_disable_SSLv2_for_openssl_1_0_0.patch https://bugs.php.net/patch-display.php\?bug_id\=54736\&patch\=debian_patches_disable_SSLv2_for_openssl_1_0_0.patch\&revision=1305414559\&download\=1

sudo patch -p1 -b < debian_patches_disable_SSLv2_for_openssl_1_0_0.patch

FreeType

sudo mkdir -pv /usr/include/freetype2/freetype

sudo ln -sf /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h

Building PHP 5.2.17

cd /opt/source/php-5.2.17

sudo ./configure –enable-cli \
–prefix=/opt/source/php-5.2.17 \
–with-pear \
–without-iconv \
–with-curl \
–with-mysqli \
–with-mysql –with-libdir=/lib/i386-linux-gnu \
–enable-mbstring \
–enable-exif \
–with-gd \
–with-zlib \
–with-zlib-dir \
–with-gettext \
–with-mhash \
–enable-ftp \
–enable-bcmath \
–with-mime-magic \
–with-pdo-mysql \
–enable-sockets \
–enable-soap \
–enable-calendar \
–enable-fastcgi \
–enable-force-cgi-redirect \
–enable-fpm

Make and install

sudo make
sudo make install

Copy php.ini

sudo cp /opt/source/php-5.2.17/php.ini-dist /opt/source/php-5.2.17/lib/php.ini

Test

/opt/source/php-5.2.17/bin/php-cgi -v

PHP 5.2.17 (cgi-fcgi) (built: Apr 20 2016 22:14:49)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

Patch and Build PHP 5.3.29 on Ubuntu Server 14.04 32 bit Server

Patch

No need

Building PHP 5.3.29

cd /opt/source/php-5.3.29/

Configure

sudo ./configure –enable-cli \
–prefix=/opt/source/php-5.3.29 \
–with-pear \
–without-iconv \
–with-curl \
–with-mysqli \
–with-mysql –with-libdir=/lib/i386-linux-gnu \
–enable-mbstring \
–enable-exif \
–with-gd \
–with-zlib \
–with-zlib-dir \
–with-gettext \
–with-mhash \
–enable-ftp \
–enable-bcmath \
–with-pdo-mysql \
–enable-sockets \
–enable-soap \
–enable-calendar \
–enable-fpm

Make and install

sudo make
sudo make install

Copy php.ini

sudo cp /opt/source/php-5.3.29/php.ini-production /opt/source/php-5.3.29/lib/php.ini

Test

/opt/source/php-5.3.29/sbin/php-fpm -v

PHP 5.3.29 (fpm-fcgi) (built: Apr 20 2016 22:29:23)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies

Patch and Build PHP 5.4.33 on Ubuntu Server 14.04 32 bit Server

Patch

No need

Building PHP 5.4.33

cd /opt/source/php-5.4.33

Configure

sudo ./configure –enable-cli \
–prefix=/opt/source/php-5.4.33 \
–with-pear \
–without-iconv \
–with-curl \
–with-mysqli \
–with-mysql –with-libdir=/lib/i386-linux-gnu \
–enable-mbstring \
–enable-exif \
–with-gd \
–with-zlib \
–with-zlib-dir \
–with-gettext \
–with-mhash \
–enable-ftp \
–enable-bcmath \
–with-pdo-mysql \
–enable-sockets \
–enable-soap \
–enable-calendar \
–enable-fpm

Make and install

sudo make
sudo make install

Copy php.ini

sudo cp /opt/source/php-5.4.33/php.ini-production /opt/source/php-5.4.33/lib/php.ini

Test

/opt/source/php-5.4.33/sbin/php-fpm -v

PHP 5.4.33 (fpm-fcgi) (built: Apr 20 2016 22:47:23)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

Patch and Build PHP 5.5.34 on Ubuntu Server 14.04 32 bit Server

Patch

No need

Building PHP 5.5.34

cd /opt/source/php-5.5.34

Configure

sudo ./configure –enable-cli \
–prefix=/opt/source/php-5.5.34 \
–with-pear \
–without-iconv \
–with-curl \
–with-mysqli \
–with-mysql –with-libdir=/lib/i386-linux-gnu \
–enable-mbstring \
–enable-exif \
–with-gd \
–with-zlib \
–with-zlib-dir \
–with-gettext \
–with-mhash \
–enable-ftp \
–enable-bcmath \
–with-pdo-mysql \
–enable-sockets \
–enable-soap \
–enable-calendar \
–enable-fpm

Make and install

sudo make
sudo make install

Copy php.ini

sudo cp /opt/source/php-5.5.34/php.ini-production /opt/source/php-5.5.34/lib/php.ini

Test

/opt/source/php-5.5.34/sbin/php-fpm -v
PHP 5.5.34 (fpm-fcgi) (built: Apr 20 2016 23:05:18)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

Patch and Build PHP 5.6.20 on Ubuntu Server 14.04 32 bit Server

Patch

No need

Building PHP 5.6.20

cd /opt/source/php-5.6.20

Configure

sudo ./configure –enable-cli \
–prefix=/opt/source/php-5.6.20 \
–with-pear \
–without-iconv \
–with-curl \
–with-mysqli \
–with-mysql –with-libdir=/lib/i386-linux-gnu \
–enable-mbstring \
–enable-exif \
–with-gd \
–with-zlib \
–with-zlib-dir \
–with-gettext \
–with-mhash \
–enable-ftp \
–enable-bcmath \
–with-pdo-mysql \
–enable-sockets \
–enable-soap \
–enable-calendar \
–enable-fpm

Copy php.ini

sudo cp /opt/source/php-5.6.20/php.ini-production /opt/source/php-5.6.20/lib/php.ini

Test

/opt/source/php-5.6.20/sbin/php-fpm -v

PHP 5.6.20 (fpm-fcgi) (built: Apr 20 2016 23:19:45)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Patch and Build PHP 7.0.5 on Ubuntu Server 14.04 32 bit Server

Patch

No need

Building PHP 7.0.5

cd /opt/source/php-7.0.5

Configure

sudo ./configure –enable-cli \
–prefix=/opt/source/php-7.0.5 \
–with-pear \
–without-iconv \
–with-curl \
–with-mysqli=/usr/bin/mysql_config \
–with-pdo-mysql=mysqlnd \
–enable-mbstring \
–enable-exif \
–with-gd \
–with-zlib \
–with-zlib-dir \
–with-gettext \
–with-mhash \
–enable-ftp \
–enable-bcmath \
–with-pdo-mysql \
–enable-sockets \
–enable-soap \
–enable-calendar \
–enable-fpm

Copy php.ini

sudo cp /opt/source/php-7.0.5/php.ini-production /opt/source/php-7.0.5/lib/php.ini

Test

/opt/source/php-7.0.5/sbin/php-fpm -v

PHP 7.0.5 (fpm-fcgi) (built: Apr 20 2016 23:37:46)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

Fiuh, a lot of copy paste 🙂 .

Many more options for configuration but I let it for my homework. At this time I need to make simple documentation for our team quick  reference .

I’ll continue to ‘glue’ all of them in nginx.conf on next post.

See you