skip to Main Content

I’m going to show you how to upgrade PHP 5.3 to PHP 5.4 on CentOS 6.7. This article is assuming that you are running the CentOS 6.7 default version of PHP 5.3.

 

1. Confirm your version of PHP is the CentOS 6.7 default

Type in the following:

rpm -qa | grep php

Should output similar to the following:

php-cli-5.3.3-46.el6_6.x86_64
php-common-5.3.3-46.el6_6.x86_64
php-5.3.3-46.el6_6.x86_64

Great, let’s move on.

 

2. Install and activate the REMI and EPEL RPM Repositories

Type in the following to download and install the required files:

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

Now to 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

Press CTRL-O to save, and CTRL-X to exit, and we can continue.

 

3. Update PHP from 5.3 to 5.4

Easy as pie, simply type in the following:

yum -y update php*

Once that’s done, we can verify:

rpm -qa | grep php

And we should see something similar to the below:

php-common-5.4.45-1.el6.remi.x86_64
php-5.4.45-1.el6.remi.x86_64
php-cli-5.4.45-1.el6.remi.x86_64

Make sure PHP is working correctly:

php -v

You should see something similar to the following:

PHP 5.4.45 (cli) (built: Sep 2 2015 18:54:00) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

And that’s all she wrote!

Sponsored Links

This Post Has 20 Comments

  1. i have the next problem, what i can do to solve it?
    Error: Paquete: php-zts-5.3.3-46.el6_6.i686 (@updates)
    Necesita: php-common(x86-32) = 5.3.3-46.el6_6
    Eliminando: php-common-5.3.3-46.el6_6.i686 (@updates)
    php-common(x86-32) = 5.3.3-46.el6_6
    Actualizado por: php-common-5.4.45-2.el6.remi.i686 (remi)
    php-common(x86-32) = 5.4.45-2.el6.remi
    Disponible: php-common-5.3.3-40.el6_6.i686 (base)
    php-common(x86-32) = 5.3.3-40.el6_6
    Disponible: php-common-5.4.45-1.el6.remi.i686 (remi)
    php-common(x86-32) = 5.4.45-1.el6.remi

    1. Hi Arturo,
      My Spanish is not the best, but from what I can tell, the issue is with package php-zts-5.3.3-46.el6_6.i686
      You might need to remove the package first in order to upgrade to PHP 5.4
      What is the output of “rpm -qa | grep php”

  2. I followed the tutorial, except forgot to put “yum -y update *php”, I only put “yum -y update”.. which updated -everything-, except my PHP. it’s still version 5.3. when I try to run “yum -y update php*” it says Package(s) *php available, but not installed. No Packages marked for Update. output of “rpm -qa | grep php” is nothing.. help?

    1. Hello,
      Something doesnt sound right there. If the output of “rpm -qa | grep php” is coming up empty, that usually means that you don’t have php installed.
      Does “php -v” give any output?

      1. Hi Andyz,
        Thanks for the reply. With some help from Remi I am now at a stage where “rpm -qa | grep php” outputs

        php-cli-5.4.45-3.el6.remi.x86_64
        php-5.4.45-3.el6.remi.x86_64
        php-common-5.4.45-3.el6.remi.x86_64

        however, php version still at 5.3..
        # php -v
        PHP 5.3.28 (cli) (built: Apr 15 2014 09:37:18)
        Copyright (c) 1997-2013 The PHP Group
        Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
        with the ionCube PHP Loader v4.0.12, Copyright (c) 2002-2011, by ionCube Ltd., and
        with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies

        1. Doh.. I just realized that your PHP is compiled from source. That’s why you’re not seeing the 5.3 package when running the rpm command.
          Without knowing the specifics of your server setup/configuration, the only thing I can recommend is that your either;
          A. Remove PHP 5.3.28 completely from your system, and install PHP5.4 from Remi
          B. Download and upgrade/install PHP 5.4 from source
          Typically, you don’t mix and match source and RPM builds, you can run into some issue.
          Sorry I can’t go into more detail here in the comments, that would be completely outside the scope of this article 🙁

          1. I see.. well thanks for your help 🙂 at least it’s clear to me now why I couldn’t see the PHP from rpm command

  3. # yum -y update php*
    Loaded plugins: fastestmirror, priorities
    Setting up Update Process
    Loading mirror speeds from cached hostfile
    Error: Cannot find a valid baseurl for repo: rpmfusion-free
    i am receveng this error what is the solution…

    1. Hey there,
      Check your /etc/yum.repos.d/ and either delete or comment out any mention of “rpmfusion-free”

  4. I appreciate you typing this up. But when you’re telling me to “Install and activate the REMI and EPEL RPM Repositories”, maybe you could spare a sentence to tell me what those are? What’s REMI? What’s EPEL? Why am I installing them when I just want a newer version of PHP?

Don't be shy, leave a reply!