Login as root to install php and common php component
# yum install php php-gd php-imap php-mysql php-pear php-xml phpxmlrpc curl libxml2 php-mbstring php-mcrypt
Verify installed php version
# php -v
Some scripts might need the latest php to run, here is the instruction to force upgrade php version 5.1.x to 5.2.X
List installed php module
# rpm -qa |grep php
php-common-5.1.6-15.el5.i386
php-cli-5.1.6-15.el5.i386
php-5.1.6-15.el5.i386
php-pdo-5.1.6-15.el5.i386
php-bcmath-5.1.6-15.el5.i386
php-ldap-5.1.6-15.el5.i386
php-devel-5.1.6-15.el5.i386
php-gd-5.1.6-15.el5.i386
php-xml-5.1.6-15.el5.i386
php-mbstring-5.1.6-15.el5.i386
php-mysql-5.1.6-15.el5.i386
php-dba-5.1.6-15.el5.i386
# nano /etc/yum.repos.d/CentOS-Testing.repo
Copy and paste below to the file
# CentOS-Testing:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to function properly.
# These packages build and install, but are waiting for feedback from testers as to
# functionality and stability. Packages in this repository will come and go during the
# development period, so it should not be left enabled or used on production systems without due
# consideration.
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
includepkgs=php*
Before updating your PHP packages you'll want to get a list of what you currently have installed. To get a list of current PHP packages run the following:
# rpm -qa |grep php
Now you can update your php
# yum update
You need to restart apache to take effect
# service httpd restart
You may verify your update by phpinfo or command below
# php -v