Upgrade PHP for CentOS 6 Using Additional Repositories

PHP 5.3 to 5.6 Upgrade for CentOS Using External Repos

CentOS Linux is often an option when configuring a Virtual Private Server (VPS). CentOS is designed for stability, being based upon Red Hat Enterprise Linux (RHEL). This means that although it has a long shelf life it may not have the latest features available to the Linux community. To help overcome this other repositories can be used to update the CentOS installation. Here is a list of some alternative repos for CentOS that provided various updated packages:

CentOS PHP UpgradeOne package that may require updating is PHP. CentOS 6 will be supported until 2020 but comes with PHP 5.3, a few point releases behind the current PHP version. In this article the PHP available in CentOS 6 is updated to a later version. This tutorial is based upon a VPS running a minimal installation of the latest version of CentOS 6, the 64 bit version. The tutorial was tested on a Virtual Machine (VM) duplicate of the VPS on a local machine to ensure that the configuration steps correctly worked before applying the upgrade to live environment. Always have a backup of live data and always test upgrades on a duplicate test system. This minimises the risk to a live system.

It is assumed that the VPS is accessed via a Secure Shell (SSH). This method of access can be duplicated on a local test environment to replicate the real world set up. To upgrade PHP log in to the VPS and install an alternative repo, then use yum to install the later PHP version. Here repositories from Les RPM de Remi is used.

This article assumes you are logged in as the root user, if you are logged in as a user with sudo ability use the sudo command where relevant.

Check the PHP Version and Installed Modules on the CentOS VPS

At the shell prompt check the version of PHP in use via the php -v command:

To see which PHP modules are installed it is common to use yum with the list installed option piped to grep:

The command yum list installed php\* does the same and lists the repos, alternatively use rpm with -qa:

Note your system may have additional PHP modules installed.

Remove PHP from the CentOS VPS

PHP 5.3 packages can be deleted, use yum with the remove option (yum remove is identical to the yum erase option). If the Apache HTTP Server is using PHP then HTTP can be stopped using httpd with the -k stop option, or better via the apachectl service script with the stop option. Check the status using service:

Remove the PHP 5.3 modules using yum remove followed by the list of modules. If installed via groups use the groupremove option. To see the if the “PHP Support” group is installed also pass “php*”:

You will need to confirm the removal with y. This may not remove dependant packages, use yum remove.

Again y to confirm removal. Similarly if not installed via groups using yum to remove all modules listed:

Install PHP 5.6 on CentOS 6 Using Remi Repositories

The website Les RPM de Remi has a releases of PHP 5.5 and PHP 5.6 available in repositories. There is detailed configuration available on the website. Here the steps to configure it for CentOS 6 are shown. Important, ensure the software using PHP on the server works with the newer version of PHP. If in doubt check with the software supplier.

Start by grabbing a couple of RPMs. This is done using the wget utility. For this tutorial the root’s home directory was used, a suitable temporary location is sufficient, the URL isn’t too long:


Then run the package manager:

Now use yum to replace the default PHP 5.3 or install PHP 5.6, enabling these new repositories:

Update (if you did not remove PHP 5.3):

Or install PHP 5.6:

You will need to confirm the action. Your installation may require other PHP modules. Check the install using php -v:

Next start or restart Apache:


Check that any website or software hosted by the VPS is working correctly.

CentOS PHP Upgraded to PHP 5.6

Leave a Reply

Your email address will not be published. Required fields are marked *

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.