Tek Eye Logo

Tek Eye

Upgrade PHP for CentOS 6 Using Additional Repositories

NOTE: This article is for archived information purposes only.

CentOS 6 to CentOS 7 Upgrade

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:

One 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:

# php -v
PHP 5.3.3 (cli) (built: Oct 30 2014 19:56:14)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

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

# yum list installed | grep "php"
php.i686 5.3.3-40.el6_6 @updates
php-cli.i686 5.3.3-40.el6_6 @updates
php-common.i686 5.3.3-40.el6_6 @updates

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

# rpm -qa "php*"
php-cli-5.3.3-40.el6_6.i686
php-common-5.3.3-40.el6_6.i686
php-5.3.3-40.el6_6.i686

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:

# service httpd status
httpd (pid 17531) is running...
# apachectl stop
# service httpd status
httpd is dead

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*":

# yum grouplist "php*"
Installed Groups:
PHP Support

# yum groupremove "PHP Support"

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

# yum remove php-common php-cli

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

# yum remove php php-common php-cli

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:

# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

And

# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Then run the package manager:

# rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

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):

# yum --enablerepo=remi,remi-php56 update php\*

Or install PHP 5.6:

# yum --enablerepo=remi,remi-php56 install php

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

# php -v
PHP 5.6.8 (cli) (built: Apr 16 2015 14:47:38)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

Next start or restart Apache:

# apachectl start

Or:

#apachectl restart

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

CentOS 6 PHP Upgrade

See Also

  • For a full list of all the articles on Tek Eye see the full site Index.

Author:  Published:  Archived:

ShareSubmit to TwitterSubmit to FacebookSubmit to Google+Submit to LinkedInSubmit to redditPrint Page

markdown CMS Small Logo Icon ↓markdown↓ CMS is fast and simple. Build websites quickly and publish easily. For beginner to expert.



Articles on:

Android, HTML, VPS, Computing, IT, Computer History, ↓markdown↓ CMS



Free Android Projects and Samples:

Android Examples, Android List Examples, Android UI Examples