Compile PHP 5.3.19 on CentOS 6.3 with Curl 7.28

new-php-logo

For this installation I choose CentOS 6.3 minimal version. You can download the ISO from the mirrors or direct download it from SYNc yourself. Once the CentOS installation is completed make sure you are connected to Internet to update the latest libraries.

 

Note: These steps are done assuming you are logged in as root user

1. Please update the available updates for the OS and restart

# yum update
# reboot

2. Install EPEL (Extra Packages for Enterprise Linux) so that you can get all the needed libraries for compiling PHP

# rpm -ivh http://fedora.mirror.nexicom.net/epel/6/x86_64/epel-release-6-7.noarch.rpm

3. Install Development Tools – Detailed User Guide

# yum groupinstall "Development Tools"

4. Install MySQL Database client

# yum groupinstall "MySQL Database client"

5. Install the following libraries which are required for different modules in PHP. Please make sure all the dependencies are met before installation

#yum install pcre-devel.x86_64 httpd.x86_64 httpd-devel.x86_64 wget.x86_64 
#yum install mlocate.x86_64 mhash.x86_64 mhash-devel.x86_64 libssh2-devel.x86_64 
#yum install openssl.x86_64 libssh2.x86_64 libxml2.x86_64 libxml2-devel.x86_64 
#yum install libmcrypt.x86_64 libmcrypt-devel.x86_64 openssl-devel.x86_64 
#yum install tidy.x86_64 libtidy.x86_64 libtidy-devel.x86_64 bzip2.x86_64 
#yum install bzip2-devel.x86_64 libjpeg.x86_64  libXpm-devel.x86_64 
#yum install libxslt.x86_64 libxslt-devel.x86_64 pcre.x86_64 pcre-devel.x86_64 
#yum install libjpeg-devel.x86_64 libpng.x86_64 libpng-devel.x86_64 libXpm.x86_64
#yum install freetype-devel.x86_64 libtool-ltdl-devel.x86_64 pcre.x86_64

6. For this installation I planned to use the latest version of curl so I had to my custom curl compilation

# cd
# wget http://c-ares.haxx.se/download/c-ares-1.9.1.tar.gz
# tar xvzf c-ares-1.9.1.tar.gz
# cd c-ares-1.9.1/
# ./configure
# make
# make install
# cd
# wget http://curl.haxx.se/download/curl-7.28.1.tar.gz
# tar xvzf curl-7.28.1.tar.gz
# cd curl-7.28.1/
# ./configure --with-libssh2 --enable-ares=/usr/local/ --enable-ipv6
# make
# make install

7. Download and compile PHP 5.3.19

# cd
# wget http://php.net/get/php-5.3.19.tar.gz/from/in1.php.net/mirror
# tar xvzf php-5.3.19.tar.gz
# cd php-5.3.19/
# ./configure --prefix=/usr/local/php-5.3.19 --with-config-file-scan-dir=/usr/local/php5.3.19/php.d --with-apxs2 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mcrypt --with-mhash --enable-mbstring --with-gettext --with-openssl --with-curl=/usr/local/ --enable-calendar --enable-exif --enable-ftp --enable-zip --enable-soap --enable-bcmath --with-xmlrpc --with-tidy=/usr --with-bz2 --with-zlib --with-pear --with-kerberos --with-xsl --with-gd --enable-gd-native-ttf --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr --with-pcre-regex --with-libdir=lib64 --with-pdo-mysql=mysqlnd
# make
# make install

8. Copy php.ini

# cp /root/php-5.3.19/php.ini-production /usr/local/php-5.3.19/lib/php.ini

9. Edit Apache conf check if “LoadModule” is present else add it.

# vi /etc/httpd/conf/httpd.conf

LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so

10. Set handler for Apache to handle PHP files

# vi /etc/httpd/conf/httpd.conf
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

11. If you are not planning to install ZendGuardLoader skip to step 13 else make sure you have disabled SElinux. Detailed instructions

12. Install ZendGuardLoader

# cd
# wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
# tar xvzf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
# cd ZendGuardLoader-php-5.3-linux-glibc23-x86_64/
# mv php-5.3.x/ /usr/lib64

Edit /usr/local/php-5.3.19/lib/php.ini and add these lines to end

[Zend]
zend_extension="/usr/lib64/php-5.3.x/ZendGuardLoader.so"
zend_loader.enable=1

13. Restart you apache and you are set

# /etc/init.d/httpd restart

It took a great deal of time to make this work and with lot of trial and errors. If anyone finds a better way to compile please do share it with me. All the best 😉

By Imthiaz

Programmer, SAAS, CMS & CRM framework designer, Love Linux & Apple products, Currently addicted to mobile development & working @bluebeetle