Wednesday, September 24, 2008

Upgrading from PHP 5.1 to 5.2 in Fedora


Its not that hard to upgrade PHP from v5.1 to v5.2. Here is how I do this (in detail):

1) Know your current PHP version:

# php -v

PHP 5.1.6 (cli) (built: Feb 23 2007 10:11:28)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

So the current version is 5.1.6 and this needs to be upgraded.

2) Check out the PHP RPMs that you have installed in your machine:

# rpm -qa | grep php

php-pdo-5.1.6-1.4
php-json-1.2.1-2.fc5
php-mysql-5.1.6-1.4
php-gd-5.1.6-1.4
php-xml-5.1.6-1.4
php-5.1.6-1.4
php-pear-1.4.9-1.2

3) Download the RPM packages for the new PHP Version. I use the website RPM.PBONE.NET since it provides a good customized search interface for finding the right RPM packages. Use "Advanced RPM Search" link near the "Search" button and you will see what I mean. Download the ones required from the desired FTP servers and place them in a folder.

(Since I am doing this for a PHP Development machine, I might use a few extra packages that might not be in your menu ;-)

pcre-6.6-1.fc5.remi.i386.rpm
php-devel-5.2.5-1.fc5.remi.i386.rpm
php-pdo-5.2.5-1.fc5.remi.i386.rpm
php-5.2.5-1.fc5.remi.i386.rpm
php-gd-5.2.5-1.fc5.remi.i386.rpm
php-pear-1.7.1-1.fc5.remi.noarch.rpm
php-cli-5.2.5-1.fc5.remi.i386.rpm
sqlite2-2.8.17-1.fc5.i386.rpm
php-common-5.2.5-1.fc5.remi.i386.rpm
php-mysql-5.2.5-1.fc5.remi.i386.rpm
sqlite2-2.8.17-1.fc5.i386.rpm.html

4) Remove the existing PHP RPMs from the machine:

# rpm -e php php-pear php-pdo php-gd php-mysql php-gd

(If this is successful, you wont get any results. If you see a message like "php-gd not found" then just remove that package from the above remove list)

5) Install the new RPMs in the below order to avoid dependency errors:

# rpm -Uvh pcre-6.6-1.fc5.remi.i386.rpm
# rpm -ivh php-common-5.2.5-1.fc5.remi.i386.rpm
# rpm -ivh php-cli-5.2.5-1.fc5.remi.i386.rpm
# rpm -ivh php-5.2.5-1.fc5.remi.i386.rpm
# rpm -ivh sqlite2-2.8.17-1.fc5.i386.rpm
# rpm -ivh php-pdo-5.2.5-1.fc5.remi.i386.rpm
# rpm -ivh php-mysql-5.2.5-1.fc5.remi.i386.rpm
# rpm -ivh php-pear-1.7.1-1.fc5.remi.noarch.rpm
# rpm -ivh php-gd-5.2.5-1.fc5.remi.i386.rpm

6) This should be over pretty quickly and you wont get any errors. Then just restart your Apache Server (HTTPD) for the changes to take effect.

# /etc/init.d/httpd restart

Now check your PHP Version and see if the change got reflected:

# php -v

PHP 5.2.5 (cli) (built: Nov 10 2007 12:15:39)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

Voila, Done!
 

A Linux Admin's WeBlog! Blak Magik is Designed by productive dreams for smashing magazine Bloggerized by Ipiet The Blog Full of Games © 2008