How to upgrade php from php5.1 to php 5.3 on CentOS

Today I am starting my first blog on “How to upgrade¬†php from php5.1 to php 5.3 on my CentOS server”.
In order to upgrade php from php5.1 to php 5.3 do following:
1) # php -v
PHP 5.1.6 (cli) (built: Jun 27 20XX 12:25:37)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

2) run following command:
# yum list installed | grep php | cut -d’ ‘ -f1
php.i386
php-cli.i386
php-common.i386

3) Now run following command:
#yum remove php php-cli php-common

This will ask you to remove above named packages. Packages are the ones which we got in (2).
Press ‘y’ when prompted. This will remove old packages.

4) Now run php -v again
# php -v

Nothing will come up.

5) Now run following command:

#yum install php53 php53-cli php53-common php53-devel php53-gd
This will prompt you to install following 5 packages:

php53.i386
php53-cli.i386
php53-common.i386
php53-devel.i386
php53-gd.i386

Press ‘y’ when prompted which will install above packages.

6) run php -v to see what version you have
# php -v
PHP 5.3.3 (cli) (built: Jun 27 2012 12:25:37)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

7) now restart your Apache server:
#service httpd restart

8) now open your preffered browser and point it to your website:
You will see following message:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

9) It means that you do not have mysql installed or not started the mysqld demon
if you don’t have mysql server installed, do following:
#yum install -y mysql mysql-server
Now ensure that MySQL and MySQL server are installed

10) Now install php-mysql
#yum install php53-mysql
This prompt you to install php53-mysql package and its necessary dependancies which in my case was php53-pdo.i386
It will prompt you to press ‘y’ or ‘N’.
Press ‘y’ when prompted which will install above packages.

11) Now ensure that PHP and the PHP MySQL components are installed using following command:
# yum list installed | grep php | cut -d’ ‘ -f1
php53.i386
php53-cli.i386
php53-common.i386
php53-devel.i386
php53-gd.i386
php53-mysql.i386
php53-pdo.i386

12) Restart Apache by
#service httpd restart

You will be good to go.

There are few good resources on this:

Upgrade PHP 5.1/5.2 to 5.3 on CentOS By Chris Jean

Step by step WordPress installation video on CentOS 5.6 by Joseph Palumbo