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

wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
   tar zxvf libmcrypt-2.5.8.tar.gz 
   cd libmcrypt-2.5.8
   ./configure 
   make
   make install

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

wget ftp://ftp.astron.com/pub/freetds/stable/freetds-stable.tgz
tar zxvf freetds-stable.tgz
cd freetds-0.91/ #in my case
./configure --prefix=/usr/local/freetds --enable-msdblib
make
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/ld.so.conf
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:

wget http://us2.php.net/get/php-5.5.5.tar.gz/from/this/mirror
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 \
        --with-mssql=/usr/local/freetds

Make & Install by typing:

make
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

Comments

  1. Bart McLeod

    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.