CentOS – update / install PHP 5.2
CentOS 5.x comes with PHP 5.1, which is too old for some applications.
Here is a quickie on how to update it using CentOS development / testing repository.
- First, create a /etc/yum.repos.d/CentOS-dev.repo file and add this content to it:
[c5-dev]
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
- As you just want to update PHP (but not all software on the server), see what PHP packages you have on the server:
# rpm -qa|grep php
php-gd-5.1.6-24.el5_4.5
php-common-5.1.6-24.el5_4.5
php-pdo-5.1.6-24.el5_4.5
php-cli-5.1.6-24.el5_4.5
php-mysql-5.1.6-24.el5_4.5
php-ldap-5.1.6-24.el5_4.5
php-5.1.6-24.el5_4.5
- Now, time to upgrade PHP to 5.2 on your CentOS 5.x server (to PHP 5.2.10, as of writing this blog entry):
# yum install php-gd php-common php-pdo php-cli php-mysql php-ldap php
Packet manager (yum) will ask if you want to install CentOS-testing GPG key – if you confirm, it will upgrade PHP to the latest version from the development repository.
- After the upgrade, make sure that your existing websites still function properly. If they do, you may want to remove /etc/yum.repos.d/CentOS-dev.repo file (or comment out its content, or disable it per yum configuration) – to prevent accidental updating of all software to development versions.
[...] CentOS – update / install PHP 5.2 [...]