Most of the yum repos doesn’t include PHP5.5.X on current releases for the time being. So if you need PHP5.5.X, you need to compile and build it for your self.

Advise: First of all, you should consider removing php packages from your server before compiling php, but beaware your codes will be visible till you install the compiled version to your server, consider shutting down your apache server for a while.

yum erase php*

Before downloading the code, install “Development Tools” by tiping:

yum groupinstall "Development Tools"

and install other related header files:

yum install httpd-devel libxml2-devel openssl-devel pcre-devel curl-devel gd-devel mysql-devel libxslt-devel

Download & install libmcrypt

   tar zxvf libmcrypt-2.5.8.tar.gz 
   cd libmcrypt-2.5.8
   make install

Download FreeTDS source, don’t use yum to install freetds-devel!

tar zxvf freetds-stable.tgz
cd freetds-0.91/ #in my case
./configure --prefix=/usr/local/freetds --enable-msdblib
make install
cp include/tds.h /usr/local/freetds/include
cp src/tds/.libs/libtds.a /usr/local/freetds/lib
echo "/usr/local/freetds/lib" >> /etc/
echo "export FREETDSCONF=/usr/local/freetds/etc/freetds.conf" >> /etc/profile
ln -s /usr/local/freetds/lib /usr/local/freetds/lib64

Download & extract php 5.5.5 release:

mv mirror php-5.5.5.tar.gz
tar zxvf php-5.5.5.tar.gz
cd php-5.5.5
./configure \
        --with-apxs2 \
        --with-curl=/usr/local/lib \
        --with-gd \
        --with-gettext \
        --with-jpeg-dir=/usr/local/lib \
        --with-freetype-dir=/usr/local/lib \
        --with-kerberos \
        --with-openssl \
        --with-mcrypt \
        --with-mhash \
        --with-mysql=/usr \
        --with-mysqli=/usr/bin/mysql_config \
        --with-pdo-mysql=/usr \
        --with-pcre-regex=/usr \
        --with-pear \
        --with-png-dir=/usr/local/lib \
        --with-xsl \
        --with-zlib \
        --with-zlib-dir=/usr/local/lib \
        --with-iconv \
        --enable-bcmath \
        --enable-calendar \
        --enable-exif \
        --enable-ftp \
        --enable-gd-native-ttf \
        --enable-soap \
        --enable-sockets \
        --enable-mbstring \
        --enable-zip \
        --enable-wddx \
        --with-libdir=lib64 \

Make & Install by typing:

make install
cp php.ini-production /etc/php.ini
sed -i 's/;date.timezone =.*/  date.timezone \= "Europe\/Istanbul"/' /etc/php.ini

Don’t forget to add respective extension to httpd.conf:

echo "AddType application/x-httpd-php .php" >> /etc/httpd/conf.d/php.conf
echo "AddType application/x-httpd-php-source .phps" >> /etc/httpd/conf.d/php.conf

and a final configuration:

sed -i 's/DirectoryIndex index.html.*/  DirectoryIndex index.html index.html.var index.php/' /etc/httpd/conf/httpd.conf

please let us know if you find any mistake

2 Responses to Build PHP5.5 on CentOS 6.4 with MSSQL Support
  1. I am following your steps to build an Ansible playbook. Enjoying it so far. In your step “Download & install libmcrypt” you have copied line numbers from a code sample. It would be better to remove those, since now you have double, non-matching line numbers on display.


Leave a Reply

Your email address will not be published. Required fields are marked *