How to install php 5.2.17 on CentOS 6.9

Long time no see 🙂 . Being busy with a few machines that got EOL phase. Yes, many legacy app require PHP 5.2.17 but developer nor the company refuse to upgrade. Now, the machine also reach end of life (CentOS 5.11) . The only option available is upgrade the OS with CentOS 6 or CentOS 7.

I use VPS to simulate the process and write it here for documentation purpose, lets get start!

Upgrade to latest CentOS 6

yum update

Install required files

yum install gcc make httpd-devel libxml2-devel bzip2-devel openssl-devel curl-devel gd-devel libc-client-devel libmcrypt-devel libmhash-devel mysql55-devel aspell-devel libxslt-devel nano wget

download php 5.2

tar -zxvf php-5.2.17.tar.gz
cd php-5.2.17


./configure --prefix=/usr/local/php52 --with-apxs2=/usr/sbin/apxs --with-config-file-path=/usr/local/lib/php52/ --disable-posix --enable-bcmath --enable-calendar --enable-exif --enable-fastcgi --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-magic-quotes --enable-mbstring --enable-pdo --enable-soap --enable-sockets --enable-wddx --enable-zip --with-bz2 --with-curl --with-curlwrappers --with-freetype-dir --with-gd --with-gettext --with-jpeg-dir --with-kerberos --with-libxml-dir --with-libxml-dir --with-mcrypt --with-mhash --with-mime-magic --with-mysql --with-mysqli --with-openssl --with-openssl-dir --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pic --with-png-dir --with-pspell --with-sqlite --with-ttf --with-xmlrpc --with-xpm-dir --with-xsl --with-zlib --with-zlib-dir

Collection off problems occured during install

problem 1 :

configure: error: libjpeg.(a|so) not found.


ln -s /usr/lib64/ /usr/lib/

problem 2 :

configure: error: libXpm.(a|so) not found.


ln -s /usr/lib64/ /usr/lib/

problem 3 :

configure: error: mcrypt.h not found. Please reinstall libmcrypt.


yum install epel-release
yum install libmcrypt-devel

problem 4 :

configure: error: Please reinstall libmhash – I cannot find mhash.h


yum install libmhash-devel

problem 5 :

configure: error: Cannot find MySQL header files under yes.


yum install mysql-server mysql-devel
ln -s /usr/lib64/mysql /usr/lib/mysql

problem 6 :

configure: error: libpng.(a|so) not found


ln -s /usr/lib64/ /usr/lib/

Install php 5.2.17

make && make install

Installing PEAR environment: /usr/local/php52/lib/php/
[PEAR] Archive_Tar – installed: 1.3.7
[PEAR] Console_Getopt – installed: 1.2.3
[PEAR] Structures_Graph- installed: 1.0.3
[PEAR] XML_Util – installed: 1.2.1
[PEAR] PEAR – installed: 1.9.1
Wrote PEAR system config file at: /usr/local/php52/etc/pear.conf
You may want to add: /usr/local/php52/lib/php to your php.ini include_path
Installing PDO headers: /usr/local/php52/include/php/ext/pdo/

Edit httpd.conf

Make sure you have these lines in httpd.conf

nano /etc/httpd/conf/httpd.conf

LoadModule php5_module /usr/lib64/httpd/modules/
AddType application/x-httpd-php .php .phtml

Start Apache and mysql service

service httpd start
service mysqld start

Make permanent service

chkconfig --level 35 httpd on
chkconfig --level 345 mysqld on

Firewall Setting

iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
service iptables save
service iptables restart