yum list installed | grep php
If packages are installed remove them, for example:
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
Step 2: Add PHP 5.4 packages to yum using this command for CentOS 5.x
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
Or, for CentOS 6.x:
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
Step 3: Now, you can check if the new PHP version packages are available:
yum list available | grep php
For, version specific search use as below command:
yum list available | grep php54
Step 4: Install the new PHP 5.4 or 5.5 packages, for example when installing PHP 5.4 packages I used:
yum install php54w.x86_64 php54w-cli.x86_64 php54w-common.x86_64 php54w-gd.x86_64 php54w-ldap.x86_64 php54w-mbstring.x86_64 php54w-mcrypt.x86_64 php54w-mysql.x86_64 php54w-pdo.x86_64
Step 5: PHP should now be upgraded to the new version, you can verify with the command:
php -v
Step 6: Restart the Web server to apply php upgrade
service httpd restart