Install or upgrade PHP 5.3 for CentOS 5.x
This article guides you through installing or upgrading PHP 5.3 on your CentOS 5.x-based system by using the third-party IUS Community Project and EPEL package repositories. These package repositories are not officially supported by CentOS, but they provide more current versions of popular applications like PHP. This article does not cover installation of the official php53 package set because the available modules in that set are limited.
Note: Exercise caution when using any third-party repository. If you have a managed support agreement, contact your provider before following the instructions in this article to ensure that you don’t create an unsupported server configuration.
Install the extra repositories
The first step is downloading and installing some RPM files that contain the additional repository definitions. Use the
rpm command, as follows:
$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm $ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm
$ wget https://centos5.iuscommunity.org/ius-release.rpm $ sudo rpm -Uvh ius-release*.rpm
After you install these files, you will see some additional repository definitions in the /etc/yum.repos.d directory.
Install the PHP 5.3 packages
This section describes how to perform a fresh installation of PHP 5.3 and any relevant additional modules that might be required. If you are upgrading from an earlier PHP version to PHP 5.3, skip to the next section.
To search for available PHP-related modules that you might want to install with PHP 5.3, run the following command:
$ yum search php
Typically the names of php modules begin with php-. Be careful about any packages that start with php53- because these will conflict with the Webtatic versions.
After you have identified the modules that you want to install, use the following command to install PHP 5.3 and the modules. Replace the module names in the following example with the ones that you want to install.
$ sudo yum install php php-cli php-gd php-mysql php-mbstring
After PHP and the modules are installed, skip to the Last steps section.
If you already have PHP installed, the steps for upgrading are slightly different from the steps for installing.
Warning: Before performing this upgrade perform a full backup of your system. The upgrade should generally be straightforward, but this will depend on the existing package state of your system.
To upgrade PHP, run the following commands. These commands check the installed PHP version and then update the existing PHP package and any associated packages to the 5.3 version in the IUS and EPEL repositories:
$ rpm -q php $ php-5.1.6-27.el5_5.3 $ sudo yum upgrade php $ rpm -q php $ php-5.3.20-1.w5
If Apache is currently running, restart it so that the new PHP version is loaded.
$ sudo /etc/init.d/httpd restart
Run the followng command to check the PHP version:
$ php -v
Carry on the conversation in the Rackspace Community.
© 2015 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER