Thursday, February 17, 2011

Installing PHP 5.2.10 on CentOS 5.5 in 6 steps

Recently I ran into the problem to update PHP on a CentOS 5.5 server from version 5.1.6 to 5.2 or higher. The reason was that I wanted to test Drupal 7 on a virtual machine the first time.
As a fact for Drupal, Drupal 7 needs PHP 5.2.5 or higher as a requirement. But a simple "php -version" revealed that CentOS only comes with version 5.1.6. Understandably, because CentOS is a server operating system an only provides stable packages in their repositories.
Anyway, a simple "yum update php" only says "nothing to do", so here is the hack to get a more recent PHP on the server:
  1. Get root.
  2. Make sure that you are only using standard PHP packages, remove the other ones (for now). You can get a list of installed php packages using the commands "rpm -qa |grep php".
  3. Add the deployment repositories through (editing) creating the file "/etc/yum.repos.d/CentOS-Testing.repo". Insert the following lines (without spaces at the start):
    [c5-testing]
    name=CentOS-5 Testing
    baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
    includepkgs=php*
  4. Update PHP through the command "yum update".
  5. Resart the Apache web server (or any webserver you use) through "service httpd restart" or "apachectl restart".
  6. Test the version of PHP:
    [root]# php -version
    PHP 5.2.10 (cli) (built: Nov 13 2009 11:44:05) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0,
    Copyright (c) 1998-2009 Zend Technologies

That pretty was it. If you had non-standard-packages, reinstall them now.

Labels: , , ,

 

6 Comments:

Anonymous Anonymous said...

thanks for the tip - PLESK 10 - CENTOS 5.5 - Worked!

- Howie

8:27 PM  
Anonymous Anonymous said...

That was really a great post about the PHP installation which would be very simple in 6 steps of installing.Thanks for sharing !

web design company

10:21 AM  
Anonymous Anonymous said...

Thanks, this is the easiest way to do it. I'm installing WebsiteBaker 2.8.3 on Centos 6 and I need to install PHP 5.2.1, your tutorial was very straightforward.

Everything went fine, great teacher!

5:12 AM  
Anonymous Anonymous said...

Sorry, I meant Centos 5.7 (was thinking of another distro)

5:17 AM  
Blogger Padam said...

Thank you!

4:17 AM  
Anonymous Anonymous said...

looked very promising but step by step on centos 5.7 64 bit... this came back with 'No Packages marked for Update".

10:27 AM  

Post a Comment

<< Home