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:
- Get root.
- 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".
- 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* - Update PHP through the command "yum update".
- Resart the Apache web server (or any webserver you use) through "service httpd restart" or "apachectl restart".
- 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: CentOS 5.5, drupal, install, PHP 5.2.10