Pages

Saturday, April 10, 2010

How to Upgrade PHP to 5.2 in CentOS

Developing a Drupal community site has been really good for a while until I needed to search a module to integrate Facebook Connect with it. I found this module specifically for that. Unfortunately, it requires PHP version 5.2, but the one on the Godaddy VPS (which is by default a CentOS flavor) is 5.1 I think. I needed to upgrade the PHP version to 5.2, and the best possible way is to install the latest rpm for CentOS and do a yum update. Here were the steps I did:



1. Login to your server using SSH then create an updated .repo file (you need to be root user to do this)

vi /etc/yum.repos.d/centos-test.repo

2. Paste the following lines in it:

[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/5/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing


3. Run a yum update:

yum update php

That's it! Your PHP installation should be updated in about 5 seconds! :)

BUT! There are known issues on this, specifically for Zend Optimizer, mcrypt and mhash PHP modules because they are the for the older version of PHP. I fixed the Zend Optimizer issue by re-installing the package itself by yum:

wget -q -O - http://www.atomicorp.com/installers/atomic.sh | sh
yum install  php-zend-optimizer


For the mcrypt and mhash issues, I just installed updated rpm packaged for these:

wget -c ftp://ftp.muug.mb.ca/mirror/centos/5.4/extras/i386/RPMS/php-mcrypt-5.1.6-15.el5.centos.1.i386.rpm
rpm -ivh --nodeps php-mhash-5.2.5-7.i386.rpm
wget -c ftp://ftp.pbone.net/mirror/yum.trixbox.org/centos/5/RPMS/php-mhash-5.2.5-7.i386.rpm
rpm -ivh --nodeps php-mcrypt-5.1.6-15.el5.centos.1.i386.rpm


Let me know if this helps or what issues you came across.

References:

http://www.freshblurbs.com/install-php-5-2-centos-5-2-using-yum

http://www.atomicorp.com/wiki/index.php/PHP


7 comments:

  1. add the end there you put the directions in the wrong order...

    you have:
    wget mcrypt
    rpm mhash
    wget mhash
    rpm mcrypt

    obviously should be:
    wget mcrypt
    rpm mcrypt
    wget mhash
    rpm mhash

    that aside, thank you for this

    ReplyDelete
  2. Thank you for posting this. It is frustrating to see that GoDaddy is still offering PHP 5.1.6 by default as of April 2010, and moreover, that their own knowledge base doesn't seem to include this particular tip (which I'm sure is not an uncommon issue). And forget about asking this by telephone. I have been meaning to experiment with Magento eCommerce but since it requires PHP 5.2, I haven't been able to, but your steps seem to have done the trick. Thanks!

    ReplyDelete
  3. Mike, can I chat with you off line about this. I'll pay you for your time or make a donation ;-) using PayPal. No prob there. I have to up date my Godaddy VPS to use PHP 5.2 also and I just want to make sure I don't break any of the site I have hosted on my vd box. Please hit me back today if you can. You can also give me a call (contact info is on my site). Thanks.
    - Alex

    ReplyDelete
  4. Mike, Thanx .. your solution worked fantastic for me...

    ReplyDelete
  5. It seems the mcrypt couldn't found in the mirror mentioned.

    ReplyDelete
  6. I have no idea if this is the correct ftps for mcrypt because I've just installed it on my VDS:

    mcrypt

    wget -c ftp://ftp.muug.mb.ca/mirror/centos/5.5/extras/i386/RPMS/php-mcrypt-5.1.6-15.el5.centos.1.i386.rpm

    ReplyDelete
  7. Yes, you are right but i don't absolutely agree. I think it's only partial right. But post is god i think.

    ReplyDelete