Updating PHP on CentOS Linux
From ISPWiki
(checked 08.09.2011 on CentOS 5.6 32bit)
CentOS Linux 5 normally comes installed with PHP 5.1.6. For later version, we would recommend that you use a third-party repository. This document describes how to update to PHP 5.2.x and 5.3.x.
Note
This article was greatly modified. Repositories were also changed, thus currently (as of 08.09.2011) we recommend using the Atomic repository for all updates or REMI if you upgrading to PHP 5.3.
Contents |
Updating PHP 5.1.6 to 5.2.x
Method 1: Atomic repository (recommended)
The most convenient means is to use the Atomic repository. CentOS guru recommend that you use it instead of CentOS-Testing due to unstable test software.
As of 08.09.2011 in the PHP 5.2.17. repository
Connect the repository:
wget -q -O - http://www.atomicorp.com/installers/atomic.sh | sh
Disable PHP 5.3 that is installed into the repository by default
exclude = php*5.3*
into [atomic] in the /etc/yum.repos.d/atomic.repo file
Update PHP
yum update php
Update the mcrypt package as well
yum update php-mcrypt
Once completed successfully, check PHP and its version:
php -v php -m
Restart Apache
/etc/init.d/httpd restart
Method 2: CentOS-Testing repository (not recommended)
(information from wiki.centos.org)
As of 15.07.2010 in the PHP 5.2.10 repository
Create a /etc/yum.repos.d/CentOS-Testing.repo file and copy/paste the following into this file: :
# CentOS-Testing: # !!!! CAUTION !!!! # This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras. # They may or may not replace core CentOS packages, and are not guaranteed to function properly. # These packages build and install, but are waiting for feedback from testers as to # functionality and stability. Packages in this repository will come and go during the # development period, so it should not be left enabled or used on production systems without due # consideration. [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 the PHP packages on your system:
yum update
Once completed restart Apache:
service httpd restart
See also wiki.centos.org for more information on how to install additional packages.
Updating PHP 5.1.6 to 5.3.x and MySQL-server 5.0 to 5.1
This section describes how to update PHP to 5.3. The MySQL-server 5.0 will also update to 5.1. as it is required for correct operation of php-mysql.
Method 1: Atomic repository (recommended)
We recommend using the Atomic repository in the same way as for updating to PHP 5.2. See above for details (when updating to 5.2). Do not specify the exception to disable PHP 5.3. in the configuration file.
PHP 5.3 will be installed
Method 2: Standard repository (not recommended)
CentOS 5.6 and later includes php52-* in the standard repository. You may install them, but some problems may occur (for example, deletion of old php will uninstall phpmyadmin and squirrelmail).
Delete PHP 5.1
rpm -e php php-mysql ....
(execute for each packet)
Install php52
yum install php52 php52-cli php52-mysql
Method 3: REMI repository (acceptable)
You may use the REMI repository instead of Atomic. The EPEL repository must be connected as its dependency.
Connecting EPEL and REMI
Connect EPEL:
For 32-bit system (execute the uname -a command to learn the system version)
rpm -ihv http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
For 64-bit CentOS Linux
rpm -ihv http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
Connect REMI (regardless the OS bit count):
rpm -ihv http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
Updating PHP and MySQL from the REMI repository
To update PHP 5.1.6 to PHP 5.3 execute the command
yum --enablerepo=remi update php mysql
REMI contains the archive http://rpms.famillecollet.com/enterprise/5/olds/ of earlier PHP versions including PHP 5.2 (they must be downloaded and installed manually, rather than via yum).
Notes
Configuring default repository
When installing a repository, the file in which the enabled=1 or enabled=0 option allows to "automatically" connect the repository is created in the /etc/yum.repos.d/ directory.
Notes for ISPmanager
Once PHP has been updated, update ISPmanager packets cache
/usr/local/ispmgr/sbin/pkgctl cache
to correctly display the version in the Applications module.
