How to Upgrade PHP 5.3.x to 5.4.x or 5.5.x on CentOS
| |A guide to successfully upgrade PHP version from 5.3.x to 5.4.x or 5.5.x on CentOS using yum command (CLI). Tutorial with pics suitable for beginners. For your information, many default LAMP stack installations come with PHP v5.3.x as it’s known as most stable version (and it has reached end of life after getting last update). But recently, many want to upgrade to 5.4 which is known as newest stable version (with minimal memory footprint) or 5.5 which is known as bleeding-edge newest version.
Should I Upgrade to Latest PHP Version?
Newer is not always better (or faster) but newer version always offers new features, improvements and enhancements which are not always available in its old version. But again, even loaded with all those new stuff, it is not always better than its old one. So, which one is you?
I want to experience with latest newest features? Upgrade to 5.5.x
I want the most stable performance? Upgrade to 5.4.x
I want the stable version that’s always compatible with many PHP scripts? Stick with 5.3.x
According to this blog, PHP 5.3 is a bit faster than 5.4 and 5.5 (approximately 7% faster than 5.4). But, from version 5.4 and upwards, the memory consumption has dropped significantly. The benchmark was done with a conclusion that PHP version 5.4 and 5.5 are practically the same with regards to speed and memory consumption. So the decision is yours.
Also read:
How to install or upgrade to PHP 7 – An extremely fast PHP version
How to Upgrade on CentOS?
This tutorial was performed on CentOS 6.5 x86 (32-bit) vps.
What you’ll need:
- Proper knowledge to use Putty or Terminal
- Basic SSH command ability
- LAMP Stack (or at least Apache and PHP 5.3 are installed)
Step 1 – Login to your server via Command Line (Putty or Terminal)
Step 2 – Add EPEL and Remi repositories onto your system:
On CentOS 6.x 32-bit
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
On CentOS 6.x x86_64 (64-bit)
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
screenshot:
Step 3 – Now enable your newly added Remi repo. Open the /etc/yum.repos.d/remi.repo repository file using a text editor of your choice – I use Nano:
nano /etc/yum.repos.d/remi.repo
Step 4 – Edit enabled=0 line to enabled=1:
4.a – Update to PHP 5.4, in [remi] section:
4.b – Update to PHP 5.5, in [remi-php55] section:
4.c – Bonus – Update to PHP 5.6 (beta version), in [remi-php56] section:
once done, Save changes (Control+O) and exit (Control+X)
Step 5 – Now update yum:
yum update -y
Step 6 – Done. Now you can check using this command:
php -v
In this example I got:
PHP 5.4.28
PHP 5.5.12
PHP 5.6.0 Beta 2
Now you can test your PHP script on your browser and hope everything still runs smoothly.
Preventing The Mess
You may have to edit old httpd.conf and php.conf (if your srcipt went messed up).
Step 1 – Make backup of php.conf file:
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.bak
Step 2 – Then edit httpd.conf file:
nano /etc/httpd/conf/httpd.conf
Step 3 – You have to find every line with php_ in it, and remove it (or simply add #). If you have found out that there is at least one line per domain, so be sure to remove them all. Once done, save and exit.
Step 4 – Finally restart httpd service (Apache):
service httpd restart
Also, you may also want to upgrade MySQL using this command:
mysql_upgrade -u root -p
That’s it. Do not forget to follow me on Twitter @serveromdotcom or download ServerMom’s official Android app to get faster information update. adiós!
I went through this but still am at PHP Version 5.3.3
try to clean the cache of repo with:
# yum clean all
Ciao!
Can we do that for Zpanel 10.1.1 that have 5.3.3? Can we follow that for 5.5.X ?
Thx for this!
I did the entire provedure and I was still having PHP 5.3.3
Then I did # yum clean all and repeat everything but I’m still having PHP5.3.3
Is there anythig else to solve the prolem?
MadManBlues, have you restarted your Apache?
Hello,
Do you know if CenOS 7 support PHP 5.5.x?
if so, can you provide the update to your article to support that upgrade?
Thanks,
Ricardo
its works, very very tanks…
dont forget to restart apache …
hello,
i have this error:
Error: Package: php-pecl-apc-3.1.9-2.el6.x86_64 (@base)
Requires: php(zend-abi) = 20090626
Removing: php-common-5.3.3-27.el6.2.x86_64 (@LocalRepo)
php(zend-abi) = 20090626
Updated By: php-common-5.4.36-1.el6.remi.x86_64 (remi)
php(zend-abi) = 20100525-x86-64
Available: php-common-5.4.35-1.el6.remi.x86_64 (remi)
php(zend-abi) = 20100525-x86-64
Error: Package: php-pecl-apc-3.1.9-2.el6.x86_64 (@base)
Requires: php(api) = 20090626
Removing: php-common-5.3.3-27.el6.2.x86_64 (@LocalRepo)
php(api) = 20090626
Updated By: php-common-5.4.36-1.el6.remi.x86_64 (remi)
php(api) = 20100412-x86-64
Available: php-common-5.4.35-1.el6.remi.x86_64 (remi)
php(api) = 20100412-x86-64
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest
Hi,
It is still say PHP version 5.3.
I have done clean all & restart the service as well. But Still its getting me PHP 5.3. And I retry the update, but it says There is no package to update. And PHP5.5 packeage shows as enabled to update (yum repolist all).
Note: When running “yum update -y”, it shows
remi-php55 | 2.9 kB 00:00
remi-php55/primary_db | 174 kB 00:00
updates | 3.4 kB 00:00
Resolving Dependencies
–> Running transaction check
—> Package kernel.x86_64 0:2.6.32-504.8.1.el6 will be installed
—> Package perl-YAML-LibYAML.x86_64 0:0.38-3.el6 will be updated
—> Package perl-YAML-LibYAML.x86_64 0:0.38-5.el6 will be an update
–> Finished Dependency Resolution
Dependencies Resolved
There is no PHP packages as per the screenshot shows. Anyone can help?
Thx. That saved a lot of minutes searching the web…
Good Article …. Nice … 🙂
Hello, thanks for the great article. It has ALMOST worked for me. I have both repos and get the same results as your screenshots, however, when I attempt to add ‘nano /etc/yum.repos.d/remi.repo’, I get a message back stating “-bash: nano: command not found” and then nothing happens. What could I be doing wrong?
you have to install nano at first (yum install nano -y) or simply use vi if you are used to it.
Hi Sawiyati, thank you for responding, it is very much appreciated.
Installing nano onto the server did indeed fix the issue.
Damien
Its works! Thanks a lot! Great work!!!! You Rock!
help me momm 🙁
\[root@panel ~]# php -v
PHP 5.4.39 (cli) (built: Mar 19 2015 06:59:35)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
my suhosin not running
This doesn’t seem to work for me either… i have the file update to 1 for 5.4. i’m currently running 5.3.29
[root@server admin]# yum clean all
Loaded plugins: fastestmirror, security
Cleaning repos: base epel extras remi updates
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@server admin]# yum update -y
Loaded plugins: fastestmirror, security
Setting up Update Process
Determining fastest mirrors
epel/metalink | 14 kB 00:00
* base: mirrors.chkhosting.com
* epel: mirror.compevo.com
* extras: mirror.us.oneandone.net
* remi: mirrors.mediatemple.net
* updates: bay.uchicago.edu
base | 3.7 kB 00:00
base/primary_db | 4.6 MB 00:00
epel | 4.4 kB 00:00
epel/primary_db | 6.5 MB 00:00
extras | 3.4 kB 00:00
extras/primary_db | 30 kB 00:00
remi | 2.9 kB 00:00
remi/primary_db | 1.1 MB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 2.7 MB 00:00
No Packages marked for Update
I followed all the steps and got below error:
======================================
Running rpm_check_debug
ERROR with rpm_check_debug vs depsolve:
php53u-pdo is needed by (installed) php53u-mysql-5.3.28-1.ius.centos6.x86_64
php53u-common = 5.3.28-1.ius.centos6 is needed by (installed) php53u-mysql-5.3.28-1.ius.centos6.x86_64
You could try running: rpm -Va –nofiles –nodigest
Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx-2015-04-17-19-46_aCx3P.yumtx
==========================
Thanks in Advance.
Wow. Thanks. Followed the tutorial and updated to PHP 5.4 in no time. Well done!
For those of you that are having problems, when you edit /etc/yum.repos.d/remi.repo, you will notice it mentions that you still need to enable the “remi” repo, even though the screenshot provided does not show that. Make sure you have both [remi] and [remi-php55] enabled. Other then that, it all worked for me.
First, thanks for doing this tutorial.
When I enter nano /etc/yum.repos.d/remi.repo I get an empty file with a “NEW FILE” option.
If I do ls -l /etc/yum.repos.d/remi.repo I get “No such file or directory.”
If I try ls -l /etc/yum.repos.d/remi* I still get “No such file or directory.”
If I do ls -l /etc/yum.repos.d/epel* I get 2 files, epel.repo and epel-testing.repo.
Any ideas what’s wrong?
One problem solved but another popped up.
I went back and looked at what the computer did at each command and discovered that with the command, “rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm” it only did the last half of the command, not the first. So I did “rpm -Uvh remi-release-6*.rpm” and now the remi.repo file is there.
After editing this file I ran yum update -y and at one point I got:
Available: php-commom-5.6.7-1.e16.remi.x86_64 (remi-php56)
php(zend-abi) = 20131226-64
Error: Package: php-mcrypt-5.3.3-3.e16.x86_64 (@epel)
Requires: php(zend-abi) = 20090626
Removing php-common-5.3.3-40.e16__6.x86_64 (@updates)
php(zend-abi) = 20090626
Updated By: php-common-5.6.8-1.e16.remi.x86_64 (remi-php56)
php(zend-abi) = 20131226-64
Then there are a bunch more “Available” lines, followed by 2 “You could try…” lines and then a new command prompt.
What should I do?
I am getting this error:
Error Downloading Packages:
libyaml-0.1.6-1.el6.x86_64: failure: libyaml-0.1.6-1.el6.x86_64.rpm from epel:
i tried using instructions to upgrade to 5.6 from 5.3,; it went successfully, but upgraded to 5.4.41 instead of 5.6.
remi file entries are correct.
succes to upgrade php, but after it when wordpress open site download index.php. need help
succes upgrade php.
but get error, opened website download index.php
need help..!
I received this error after I execute “yum update -y”
[root@chacha /]# yum update -y
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
Hello,
I am in the step 3 “Step 3 – You have to find every line with php_ in it, and remove it (or simply add #). If you have found out that there is at least one line per domain, so be sure to remove them all. Once done, save and exit.”
But get this
[root@Server ~]# service httpd restart
Stopping httpd: [FAILED]
Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
[Tue Jul 28 11:44:26 2015] [warn] NameVirtualHost *:8080 has no VirtualHosts
[FAILED]
HELP
root@server [~]# yum update -y
Loaded plugins: fastestmirror, security
Setting up Update Process
Loading mirror speeds from cached hostfile
* base: centos.host-engine.com
* epel: mirror.steadfast.net
* extras: mirror.cisp.com
* remi-php55: mirrors.mediatemple.net
* updates: cosmos.cites.illinois.edu
No Packages marked for Update
root@server [~]# php -v
PHP 5.4.41 (cli) (built: Jun 9 2015 14:31:09)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with the ionCube PHP Loader v4.7.5, Copyright (c) 2002-2014, by ionCube Ltd., and
with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies
Hello, my server error500.html , when I update repo. Helpme!!
Hi, Srs !
My environment is PHP 5.3.3 to PHP 5.5.30
Transaction Check Error:
file /usr/lib64/mysql/libmysqlclient.so.16.0.0 from install of compat-mysql51-5.1.54-1.el6.remi.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
file /usr/lib64/mysql/libmysqlclient_r.so.16.0.0 from install of compat-mysql51-5.1.54-1.el6.remi.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
you should prolly mention it’s better to use “yum -y update php*” .. I did just “yum -y update” and it’s updating EVERYTHING on my server.. 502 items. oops!
Oh hell!! I lost all my configuration with your update code.
Thanks.