skip to Main Content

In this article, I’m going to show you how to upgrade PHP 5.3 to PHP 5.6 on CentOS 6.7.

This article assumes you have a stock installation of CentOS, and that you already have PHP 5.3 installed

 

1. Verify current version of PHP

Type in the following to see the current PHP version:

php -v

Should output something like:

PHP 5.3.3 (cli) (built: Jul 9 2015 17:39:00) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Great, now we can move on!

 

2. Install the Remi and EPEL RPM repositories

If you haven’t already done so, install the Remi and EPEL repositories

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Enable the REMI repository globally:

nano /etc/yum.repos.d/remi.repo

Under the section that looks like [remi] make the following changes:

[remi]
name=Remi's RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Also, under the section that looks like [remi-php55] make the following changes:

[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Type CTRL-O to save and CTRL-X to close the editor

 

3. Upgrade PHP 5.3 to PHP 5.6

Now we can upgrade PHP. Simply type in the following command:

yum -y upgrade php*

Once the update has completed, let’s verify that you have PHP 5.6 installed:

php -v

Should see output similar to the following:

PHP 5.6.14 (cli) (built: Sep 30 2015 14:07:43) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

You’re done!

Sponsored Links
This Post Has 63 Comments
  1. It not works:

    $ yum -y upgrade php*
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * base: mirror.h1host.ru
    * epel: mirror.yandex.ru
    * extras: mirror.h1host.ru
    * remi: mirror.h1host.ru
    * remi-php56: mirror.h1host.ru
    * remi-safe: mirror.h1host.ru
    * updates: mirror.h1host.ru
    * webtatic: uk.repo.webtatic.com
    Setting up Upgrade Process
    No Match for argument: php.info
    No package php.info available.
    No Packages marked for Update

  2. I get the same…
    Loaded plugins: fastestmirror
    Setting up Upgrade Process
    Loading mirror speeds from cached hostfile
    * base: centos.hyve.com
    * epel: mirrors.coreix.net
    * extras: mirror.vorboss.net
    * remi: remi.check-update.co.uk
    * remi-php56: remi.check-update.co.uk
    * remi-safe: remi.check-update.co.uk
    * updates: mirror.vorboss.net
    remi | 2.9 kB 00:00
    remi-php56 | 2.9 kB 00:00
    No Match for argument: php.d
    No package php.d available.
    No Match for argument: php.ini
    No package php.ini available.
    No Packages marked for Update

    1. Hey Steve,
      Enter the following commands and send me the output:
      php -v
      rpm -qa | grep php
      cat /etc/redhat-release

      Could be that you’re running an older version of CentOS, or have PHP compiled from source. The output from Yum looks a little funky too:
      No Match for argument: php.d
      No package php.d available.
      No Match for argument: php.ini
      No package php.ini available.

      It shouldn’t be looking for php.d or php.ini as packages, because those don’t exist :/

    1. Hello,
      The mirror is correct. I think the issue lies with your system. Are your nameservers configured in /etc/resolv.conf? Are you behind a proxy?
      Try cleaning yum up:

      yum clean metadata
      yum clean all

  3. Hi Andy,
    Thanks for the guide.
    I tried to follow it but I am getting a reply of:
    No match for argument: phpunit.xml.dist
    No package phpunit.xml.dist available
    no packages marked for update
    My CentOs version is 6.7 (Final)
    PHP version: 5.3.29 (cli)
    If would be great if you could help me on this.
    Thanks

    1. Hey James,
      I’d love to help out, but first, I need a little more information.
      Can you run the following commands for me:
      rpm -qa | grep php
      ls -l /etc/yum.repos.d/
      Thanks!

  4. Problems above are caused by the shell expanding php* to whatever php* files are located in the current directory.
    To solve this, just quote the php* argument, such as:
    yum -y upgrade “php*”

  5. Hi Andy,
    I tried it but get few errors like that :
    Error: Package: 1:php54w-pear-1.10.1-1.w6.noarch (@webtatic)
    Requires: php54w-ftp
    Removing: php54w-common-5.4.45-2.w6.x86_64 (@webtatic)
    php54w-ftp
    Obsoleted By: php-common-5.6.23-1.el6.remi.x86_64 (remi-php56)
    Not found
    ——————————————————–
    Information about my server :
    [[email protected] ~]# rpm -qa | grep php
    suphp-iworx-0.7.1-108.rhe6x.iworx.x86_64
    php54w-process-5.4.45-2.w6.x86_64
    interworx-phpmyadmin-3.5.4-1137.iworx.noarch
    suphp-0.7.2-101.iworx.x86_64
    php54w-pdo-5.4.45-2.w6.x86_64
    php54w-xml-5.4.45-2.w6.x86_64
    php54w-pecl-apc-3.1.13-3.w6.x86_64
    php54w-pear-1.10.1-1.w6.noarch
    php54w-cli-5.4.45-2.w6.x86_64
    php54w-devel-5.4.45-2.w6.x86_64
    php54w-xmlrpc-5.4.45-2.w6.x86_64
    php54w-pecl-memcache-3.0.8-2.w6.x86_64
    php54w-common-5.4.45-2.w6.x86_64
    php54w-5.4.45-2.w6.x86_64
    php54w-gd-5.4.45-2.w6.x86_64
    php54w-pecl-zendopcache-7.0.5-1.w6.x86_64
    php-iworx-5.5.36-1.rhe6x.iworx.x86_64
    php54w-mysql-5.4.45-2.w6.x86_64
    php54w-mbstring-5.4.45-2.w6.x86_64
    ls -l /etc/yum.repos.d/
    total 64
    -rw-r–r– 1 root root 827 Jan 4 17:34 atomic.repo
    -rw-r–r– 1 root root 1991 May 18 21:47 CentOS-Base.repo
    -rw-r–r– 1 root root 647 May 18 21:47 CentOS-Debuginfo.repo
    -rw-r–r– 1 root root 289 May 18 21:47 CentOS-fasttrack.repo
    -rw-r–r– 1 root root 630 May 18 21:47 CentOS-Media.repo
    -rw-r–r– 1 root root 6259 May 18 21:47 CentOS-Vault.repo
    -rw-r–r– 1 root root 957 Nov 5 2012 epel.repo
    -rw-r–r– 1 root root 1056 Nov 5 2012 epel-testing.repo
    -rw-r–r–. 1 root root 3997 Nov 27 2014 interworx.repo
    -rw-r–r– 1 root root 1177 Dec 9 2015 remi-php70.repo
    -rw-r–r– 1 root root 2340 Jun 25 12:50 remi.repo
    -rw-r–r– 1 root root 449 Dec 9 2015 remi-safe.repo
    -rw-r–r– 1 root root 966 Jul 4 2015 webtatic-archive.repo
    -rw-r–r– 1 root root 868 Jul 4 2015 webtatic.repo
    -rw-r–r– 1 root root 966 Jul 4 2015 webtatic-testing.repo
    I’m lost :/
    Thank you for your help

      1. Hey,
        Unfortunately, this article may not suit your needs. You have a ton of extra packages/modules installed as well, which are going to conflict with this method. Keep in mind, this article was written for STOCK installations of PHP 5.3!

  6. Thanks! Worked straight off without a hitch. Only thing different for me was I didn’t have a [remi-php56] section in my /etc/yum.repos.d/remi.repo so I just pasted it in.

  7. I tried this steps on a test CentOS 6.7 and upgrade was smooth and fast, then I tried again with a VPS the same CentOS version but running into dependency error
    Error: Package: gd-last-2.2.3-1.el6.remi.x86_64 (remi)
    Requires: libwebp.so.5()(64bit)
    Any advise or help will be much appreciated.
    thanks.

    1. Hey there,
      So sorry for the delayed response >_< I would need to see the full yum output to be able to provide a precise diagnosis. This could be caused by any numbers of reasons, some not even related to PHP at all. Thank you!

  8. Hey, Thank you for your advice.
    Unfortunately, my system’s a little b***h… Now, all PHP files aren’t parsed correctly but offered for downloading.
    Where’s my mistake?
    Should i mention that I’ve a running webmin / virtualmin environment with about 200 vhosts?
    I was very thankful for every advice. Otherwise I had to downgrade.
    Thanks
    patrick

    1. Hey Patrick,
      Sorry about the late response here, and for reading about your troubles 🙁
      Your issue sounds like its related to Apache/permissions more than PHP, however, it could also be that mod_php is not being loaded up into Apache. To precisely diagnose this, I would have to see your configuration.
      In any case, please bear in mind that this guide was intended for people upgrading a stock/default installation of PHP 5.3 on CentOS without a control panel.
      Thank you for the kind words!

    1. Hello,
      You would basically need to follow the steps in the guide, in reverse. Please make sure that you’re following this guide using a stock/default PHP installation.

  9. How about this?
    “`
    [[email protected] vagrant_data]# yum -y upgrade php*
    Loaded plugins: fastestmirror
    Setting up Upgrade Process
    Loading mirror speeds from cached hostfile
    * base: mirrors.viethosting.vn
    * epel: mirrors.digipower.vn
    * extras: mirrors.viethosting.vn
    * remi: mirrors.thzhost.com
    * remi-php56: mirrors.thzhost.com
    * remi-safe: mirrors.thzhost.com
    * updates: mirrors.viethosting.vn
    No Match for argument: phpinfo.php
    No package phpinfo.php available.
    No Packages marked for Update
    “`

    1. I am however getting the following error – any pointers appreciated:
      –> Running transaction check
      —> Package libwebp.x86_64 0:0.4.3-3.el6 will be installed
      —> Package libzip-last.x86_64 0:1.1.3-1.el6.remi will be installed
      —> Package php-common.x86_64 0:5.3.3-48.el6_8 will be updated
      –> Processing Dependency: php(api) = 20090626 for package: uuid-php-1.6.1-10.el6.x86_64
      –> Processing Dependency: php(zend-abi) = 20090626 for package: uuid-php-1.6.1-10.el6.x86_64
      –> Finished Dependency Resolution
      Error: Package: uuid-php-1.6.1-10.el6.x86_64 (@base)
      Requires: php(api) = 20090626
      Removing: php-common-5.3.3-48.el6_8.x86_64 (@updates)
      php(api) = 20090626
      Updated By: php-common-5.6.30-1.el6.remi.x86_64 (remi-php56)
      php(api) = 20131106-64
      Available: php-common-5.3.3-47.el6.x86_64 (base)
      php(api) = 20090626
      Available: php-common-5.4.45-11.el6.remi.x86_64 (remi)
      php(api) = 20100412-x86-64
      Available: php-common-5.4.45-12.el6.remi.x86_64 (remi)
      php(api) = 20100412-x86-64
      Available: php-common-5.6.29-1.el6.remi.x86_64 (remi-php56)
      php(api) = 20131106-64
      Error: Package: uuid-php-1.6.1-10.el6.x86_64 (@base)
      Requires: php(zend-abi) = 20090626
      Removing: php-common-5.3.3-48.el6_8.x86_64 (@updates)
      php(zend-abi) = 20090626
      Updated By: php-common-5.6.30-1.el6.remi.x86_64 (remi-php56)
      php(zend-abi) = 20131226-64
      Available: php-common-5.3.3-47.el6.x86_64 (base)
      php(zend-abi) = 20090626
      Available: php-common-5.4.45-11.el6.remi.x86_64 (remi)
      php(zend-abi) = 20100525-x86-64
      Available: php-common-5.4.45-12.el6.remi.x86_64 (remi)
      php(zend-abi) = 20100525-x86-64
      Available: php-common-5.6.29-1.el6.remi.x86_64 (remi-php56)
      php(zend-abi) = 20131226-64
      You could try using –skip-broken to work around the problem

  10. Just to let you i have common php conflict in php 7 and 5 and i manually removed web static and all other files from /etc/yum /yum.repos.d and it solved the problem.
    and followed this site and it worked like charm.
    Brilliant. Thanks
    ravi

  11. First of all, thanks so much!!
    But I wasnt able to update.. this is the message I got
    Error: Package: gd-last-2.2.4-1.el6.remi.x86_64 (remi)
    Requires: libwebp.so.5()(64bit)
    Error: Package: php-mysql-5.4.45-13.el6.remi.x86_64 (remi)
    Requires: php-pdo(x86-64) = 5.4.45-13.el6.remi
    Removing: php-pdo-5.4.16-42.el7.x86_64 (@base)
    php-pdo(x86-64) = 5.4.16-42.el7
    Updated By: php-pdo-5.6.30-1.el6.remi.x86_64 (remi-php56)
    php-pdo(x86-64) = 5.6.30-1.el6.remi
    Available: php-pdo-5.4.45-13.el6.remi.x86_64 (remi)
    php-pdo(x86-64) = 5.4.45-13.el6.remi
    Available: php-pdo-5.6.29-1.el6.remi.x86_64 (remi-php56)
    php-pdo(x86-64) = 5.6.29-1.el6.remi
    Error: Package: php-5.6.30-1.el6.remi.x86_64 (remi-php56)
    Requires: httpd-mmn = 20051115
    Installed: httpd-2.4.6-40.el7.centos.4.x86_64 (@updates)
    httpd-mmn = 20120211
    httpd-mmn = 20120211×8664
    httpd-mmn = 20120211-x86-64
    Available: httpd-2.4.6-45.el7.centos.x86_64 (base)
    httpd-mmn = 20120211×8664
    httpd-mmn = 20120211-x86-64
    httpd-mmn = 20120211
    Available: httpd-2.4.6-45.el7.centos.4.x86_64 (updates)
    httpd-mmn = 20120211×8664
    httpd-mmn = 20120211-x86-64
    httpd-mmn = 20120211
    You could try using –skip-broken to work around the problem
    You could try running: rpm -Va –nofiles –nodigest
    I tried using –skip-broken, then rebooted, but my version is still 5.4 🙁
    Would really appreciate if you could help.. any other data you may need?

  12. Good tutorial. Lotsa steps. I use both Linux and Windows for various things, so I’ve got a method that’s a few steps shorter. 1) download PHP 5.6 2) put the folder location in your PATH. Boom. You’re done. Because it’s a hellava lot easier to deal with it on Windows, plus there are more tools for it.

  13. so many thanks. works great! I just upgraded from 5.3.3 to 5.6.31 on CentOS 6.
    my trick: I have to run
    nano /etc/yum.repos.d/epel.repo
    uncomment baseurl to
    [epel]
    baseurl=http://mirror2.totbb.net/epel/6/$basearch
    [epel-debuginfo]
    baseurl=http://mirror2.totbb.net/epel/6/$basearch/debug

  14. Is there any issue when I’m having the following messages:
    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/apc.so’ – /usr/lib64/php/modules/apc.so: undefined symbol: zend_unmangle_property_name in Unknown on line 0
    PHP Warning: PHP Startup: ldap: Unable to initialize module
    Module compiled with module API=20090626
    PHP compiled with module API=20131226
    These options need to match
    in Unknown on line 0
    PHP Warning: PHP Startup: memcache: Unable to initialize module
    Module compiled with module API=20090626
    PHP compiled with module API=20131226
    These options need to match
    in Unknown on line 0

  15. Its not working for me I need to update from php5.4.43 to php5.6.x
    OS version is CentOS release 6.10 (Final)
    I tried other approach also but system is not updating to php5.6 version1
    sudo yum -y upgrade php*
    Loaded plugins: fastestmirror, replace
    Setting up Upgrade Process
    Loading mirror speeds from cached hostfile
    * base: mirrors.sonic.net
    * centosplus: repos.lax.quadranet.com
    * contrib: repos.lax.quadranet.com
    * epel: mirrors.develooper.com
    * epel-debuginfo: mirrors.develooper.com
    * epel-source: mirrors.develooper.com
    * extras: mirror.sfo12.us.leaseweb.net
    * remi-php56: mirrors.mediatemple.net
    * remi-safe: mirrors.mediatemple.net
    * rpmforge: mirror.hmc.edu
    * updates: mirrors.usc.edu
    * webtatic: us-east.repo.webtatic.com
    * webtatic-debuginfo: us-east.repo.webtatic.com
    * webtatic-source: us-east.repo.webtatic.com
    No Match for argument: php-work
    No package php-work available.
    No Packages marked for Update

  16. “base | 1.1 kB 00:00
    epel | 3.6 kB 00:00
    extras | 2.1 kB 00:00
    flexbox | 1.9 kB 00:00
    remi | 2.5 kB 00:00
    remi-php56 | 2.5 kB 00:00
    remi-php56/primary_db | 177 kB 00:00
    updates | 1.9 kB 00:00
    Setting up Upgrade Process
    No Match for argument: php-5.3.3
    No package php-5.3.3 available.
    No Match for argument: php-5.3.3.tar.gz
    No package php-5.3.3.tar.gz available.
    No Packages marked for Update”
    my php is still on 5.3.3

Don't be shy, leave a reply!