How to upgrade PHP 5.1 to PHP 5.3 using yum on CentOS



This information explains how to update the standard PHP 5.1.x packages in CentOS 5.x 32-bit to the current development versions 5.3.x. These guidelines were designed using CentOS 5.5 32-bit and with the following PHP packages installed:
# 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

Provided that you're using the standard PHP packages on your CentOS server you won't need to do anything additional. If you're using additional PHP packages that aren't part of the standard CentOS repositories (like php-mcrypt) you'll have to remove them or find out updated versions of them.

Add the Atomic repositories


First thing we need to do is add the atomic repositories to yum. When we add the atomic repository we're going to configure it so it only pulls PHP packages. To start we'll need create a new yum repository configuration file (use your favorite editor):
 #  wget -q -O - http://www.atomicorp.com/installers/atomic | sh

Output: 
  Atomic Archive installer, version 2.0.9

BY INSTALLING THIS SOFTWARE AND BY USING ANY AND ALL SOFTWARE
PROVIDED BY ATOMICORP LIMITED YOU ACKNOWLEDGE AND AGREE:

THIS SOFTWARE AND ALL SOFTWARE PROVIDED IN THIS REPOSITORY IS
PROVIDED BY ATOMICORP LIMITED AS IS, IS UNSUPPORTED AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ATOMICORP LIMITED, THE
COPYRIGHT OWNER OR ANY CONTRIBUTOR TO ANY AND ALL SOFTWARE PROVIDED
BY OR PUBLISHED IN THIS REPOSITORY BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

Do you agree to these terms? (yes/no) [Default: yes]

Configuring the [atomic] yum archive for this system

Installing the Atomic GPG key: OK
Downloading atomic-release-1.0-16.el5.art.noarch.rpm: OK



The Atomic Rocket Turtle archive has now been installed and configured for your system
The following channels are available:
  atomic          - [ACTIVATED] - contains the stable tree of ART packages
  atomic-testing  - [DISABLED]  - contains the testing tree of ART packages
  atomic-bleeding - [DISABLED]  - contains the development tree of ART packages

Update PHP packages


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 use yum to update the PHP packages on your system:
 # yum update php

You should be shown a list of packages that are going to be updated. Compare it to the list of PHP packages on your system. Note any packages that are not in the list. You'll need to remove these packages or find updates for them because they won't work after you update to PHP 5.3.x. If that is acceptable type "y" to continue and let yum update the packages.
Once yum has completed restart Apache:
  # yum update php-pecl-memcache

You should also update a php-pecl-memcache package. if not then you will get following error while checking php version.
# php -v
PHP Warning:  PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20050922
PHP    compiled with module API=20090626
These options need to match
 in Unknown on line 0
PHP 5.3.22 (cli) (built: Feb 22 2013 09:51:31)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
Once yum has completed restart Apache:
 # service httpd restart

To verify the update is working create a simple testing.php in your www directory with the following source code:
<?php
  phpinfo();
?>

and open it in a web browser. The new PHP version should be reflected at the top of the page.

Conclusion


You should now have PHP 5.3.22 running on CentOS 5.5 32-bit.
 # rpm -qa |grep php

php-cli-5.3.22-15.el5.art
php-mbstring-5.3.22-15.el5.art
php-xml-5.3.22-15.el5.art
php-pear-1.4.9-8.el5
php-pdo-5.3.22-15.el5.art
php-ldap-5.3.22-15.el5.art
php-devel-5.3.22-15.el5.art
php-mysql-5.3.22-15.el5.art
php-snmp-5.3.22-15.el5.art
php-common-5.3.22-15.el5.art
php-gd-5.3.22-15.el5.art
phpmyadmin-2.11.11.3-2.el5.rf
php-5.3.22-15.el5.art
php-mcrypt-5.3.22-15.el5.art
php-pecl-memcache-3.0.6-1.el5.art


 # php -v
  
PHP 5.3.22 (cli) (built: Feb 22 2013 09:51:31)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

Remove the Atomic repositories


After updating PHP we need to do is remove the atomic repositories from yum. 
 yum -y remove atomic-release*


Comments

Popular posts from this blog

How To Add Print Button to Blogger Posts

INSTALL CISCO VPN CLIENT ON WINDOWS 10 (32 & 64 BIT). FIX REASON 442