Installing PHP 5.3.29 on CentOS 6.6 from Compiling Source

Preface

Since the offical php team released the last php 5.3.x version on Aug 14, 2014., it’s hard to find a source/repo to install php 5.3 via apt-get or yum now.

The most of popular linux distributions such as Ubuntu and CentOS had also end its support for php 5.3, the default php version replaced by 5.4 at least.

Unfortunately, there are still many apps which written in php 5.3 below and only compatitable with that in China.

So, in order to run those apps properly, I’ve to install the latest 5.3 series (5.3.29) from source code.

This article was trying to note the progress of installation, if you’ve the same requirement, you may check the following steps.

1. Preparation

1
2
3
4
5
6
7
$ yum -y install epel-release             # some libs require this repo
$ yum -y groupinstall 'Development Tools'
$ yum -y install libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel openssl-devel libtool-ltdl-devel
$ mkdir -p ~/download
$ cd ~/download
$ wget http://cn2.php.net/distributions/php-5.3.29.tar.gz
$ tar zxvf php-5.3.29.tar.gz && cd php-5.3.29

2. Configuring Source

2.1 with mysqlnd (recommended)
1
$ ./configure --prefix=/opt/php-5.3.29 --with-config-file-path=/opt/php-5.3.29/etc --enable-fpm --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-zlib --with-libxml-dir --enable-xml --with-curl --with-openssl --with-mhash --with-xmlrpc --with-gettext --with-freetype-dir --with-jpeg-dir --with-png-dir --with-gd --enable-gd-native-ttf --with-mcrypt --enable-bcmath --enable-shmop --enable-exif --enable-sysvsem --enable-mbregex --enable-mbstring --enable-sockets --enable-ftp --enable-zip --enable-soap
2.2 with mysql-devel
1
$ ./configure --prefix=/opt/php-5.3.29 --with-config-file-path=/opt/php-5.3.29/etc --enable-fpm --with-mysql=/usr/lib64/mysql --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr/bin/mysql_config --with-iconv-dir --with-zlib --with-libxml-dir --enable-xml --with-curl --with-openssl --with-mhash --with-xmlrpc --with-gettext --with-freetype-dir --with-jpeg-dir --with-png-dir --with-gd --enable-gd-native-ttf --with-mcrypt --enable-bcmath --enable-shmop --enable-exif --enable-sysvsem --enable-mbregex --enable-mbstring --enable-sockets --enable-ftp --enable-zip --enable-soap --with-libdir=lib64

3. Installation

1
$ make && make install

4. Post-Installation Configuration

1
2
3
4
5
6
$ cp php.ini-production /opt/php-5.3.29/etc/php.ini
$ cp /opt/php-5.3.29/etc/php-fpm.conf.default /opt/php-5.3.29/etc/php-fpm.conf
$ cp sapi/fpm/init.d.php-fpm /etc/init.d/php53-fpm
$ chmod 755 /etc/init.d/php53-fpm
$ chkconfig php53-fpm on
$ /etc/init.d/php53-fpm start