ZeroStopBits

How to Upgrade PHP 5.3 to PHP 5.4 on CentOS 6.7

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!

20 Comments

arturo

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

andyz

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”

Mauricio

great tutorial thank for everything!
Regards,
Mauricio

andyz

Glad it worked out for you!

Anja

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?

andyz

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?

Anja

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

andyz

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 🙁

Anja

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

Hung

Very helpfull. Thanks a lot 🙂

andyz

Hey! No problem! 🙂

omer

# 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…

andyz

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

tkanes

This is a good one !!!

Amarsir

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?

Estilo Vaidosa

Muito obrigado funcionou perfeitamente! thanks perfect !!

andyz

Muchos gracias, de nada!

Alexandru

Great tutorial, it worked like a charm. Nice work mate!

Tahir

This is awesome. How can we revert back to php 5.3 after upgraded to php 5.4?

Paul

Perfect tutorial, thank you!

Comments are closed. Need a hand with something? Contact us.

Need a server to practise on?

Spin up a KVM VPS and follow along with any of these tutorials without risking your production boxes.