Download the latest and stable version of php from http://www.php.net and run the following commands (make sure that you have the super user privileges and should have necessary compilers available in the system)
# yum install bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libc-client-devel.i686 libc-client-devel libmcrypt-devel -y
# wget -O php-5.6.6.tar.gz http://pl1.php.net/get/php-5.6.6.tar.gz/from/this/mirror
# tar -zxvf php-5.6.6.tar.gz
# cd php-5.6.6
# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# yum install libxml2-devel libmcrypt libmcrypt-devel -y
# ./configure --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-imap --with-imap-ssl --with-kerberos --enable-mbstring --with-mcrypt --with-mhash --with-mysql --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-zlib-dir --with-regex --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-soap --enable-sockets --with-xmlrpc --enable-zip --with-zlib --enable-inline-optimization --enable-mbregex --enable-opcache --enable-fpm --prefix=/usr/local/php
# make && make test && make install
# cp php.ini-development /usr/local/lib/php.ini
Write on apache configure file in the end.
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
Write this file in document root.
# vi test.php {Test file for php }
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
?>
Save and exit.
Restart apache
Once you have successfully completed the above steps create a php test file and try browsing it in browser.