How to Upgrade PHP 5.6 to PHP 7.2 on CentOS VestaCP

by Sandeep B.

In this tutorial I’ll show you how to upgrade PHP 5.6.xx which is by default installed by Vesta CP during installation to PHP 7.2.xx latest, I’ve tested on many server before writing this tutorial and its just working fine without any issue hence it is safe to upgrade to PHP 7.2, part of this tutorial is copied from remi repository.

Why upgrade to php 7.2 –  Because it will give you security & performance boost + KICK, since WordPress will load much faster and uses less resources.

Upgrade to php 7.3 : https://www.mysterydata.com/how-to-upgrade-php-5-6-to-php-7-3-on-centos-vestacp/

STEP 1 :

Install Remi Repository and EPEL Repository on your server :

RHEL 7

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
subscription-manager repos --enable=rhel-7-server-optional-rpms

RHEL 6

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
rhn-channel --add --channel=rhel-$(uname -i)-server-optional-6

CentOS 7

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

CentOS 6

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

STEP 2 :

After you have installed repository you need to follow some extra configurations :

Run this command one by one for RHEL or CentOS

yum install yum-utils
yum-config-manager --enable remi-php72

 STEP 3 :

Now just run this command :

yum update -y

You’ll see php packages are getting updated, After the update process you need to restart Apache server/php-fpm-(nginx) and check the php version from by below mentioned command:

php -v
[root@server ~]# php -v
PHP 7.2.7 (cli) (built: Jun 20 2018 08:21:26) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.7, Copyright (c) 1999-2018, by Zend Technologies

Troubleshoot

If php upgrade process fails (no update/nothing happens) or you upgraded previously from 5.6 to 7.0/7.1 then you need to run this commands to disable php 5.6/7.0/7.1 :

yum-config-manager --disable remi-php56
yum-config-manager --disable remi-php70
yum-config-manager --disable remi-php71

After that follow the tutorial from STEP 2 again.

If this post helps you in any way please consider a donation

Donate with PayPal :

md-donate

You may also like

28 comments

Rahul June 22, 2018 - 10:17 am

Thanks, it works.

Reply
Diego July 5, 2018 - 3:03 am

Many thanks!!!

Reply
sanoj July 26, 2018 - 7:49 pm

it is working.. thanks dear

Reply
sanoj July 26, 2018 - 8:07 pm

after the update, PHP 7 DNS server can’t start.. Error: named restart failed
pls help ne

Reply
Sandy July 27, 2018 - 8:58 am

how php upgrade break bind/named service, i didn’t understand and technically it is impossible. Check the status for named service why it is stopped.

Reply
SJC August 16, 2018 - 2:24 pm

Worked a treat, thank you for sharing!

Reply
David Wampamba August 24, 2018 - 8:07 am

This worked like a charm.
Thank you.

Reply
Egor September 3, 2018 - 5:28 pm

All site perfectly!
phpMyAdmin:

PHP 5.5+ is required.
Currently installed version is: 5.4.45

Reply
Sandy September 3, 2018 - 7:03 pm

you need to have php 5.6 or php 7

Reply
Madz September 24, 2018 - 11:12 am

Thanks for the info.

Im getting phpmyadmin 404 error after the upgrade..

Anything I need to edit to make it work again?

Reply
Sandy September 24, 2018 - 6:57 am

probably you tried lots of tutorial and finally upgraded the php from our site’s tutorial, you can try to reinstall phpmyadmin
yum reinstall phpmyadmin

if it doesn’t work

try this instead :

yum remove phpmyadmin -y && yum install phpmyadmin -y

and don’t forget to restart the web-server

Reply
fernan September 27, 2018 - 4:53 am

Does RoundCube webmail work with this upgrade?

Reply
Sandy September 27, 2018 - 6:13 am

Yes sure.

Reply
Tony October 17, 2018 - 3:05 am

Is it upgrade php-fpm too ?

Reply
Sandy October 16, 2018 - 9:46 pm

Yes

Reply
Jesus Rivas January 2, 2019 - 5:34 pm

Excellente article.

Thanks

Reply
Andres January 8, 2019 - 5:24 pm

How to upgrade to php 7.3?

Reply
Mohammed March 31, 2019 - 5:34 am

Great tutorial

My Current PHP Version is 5.4.45 installed on Centos 6.9. I need to Upgrade it to PHP 7.2

I followed steps as mentioned and on running php update -y but I get the following error

Error: Package: gd-last-2.2.5-5.el6.remi.x86_64 (remi)
Requires: libwebp.so.5()(64bit)
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest

Kindly can you help me resolve this

Thanks

Reply
Sandy March 31, 2019 - 8:43 am

hi install epel release on you server and try to do the steps again
yum install epel-release
then install
yum --enablerepo=epel install libwebp libwebp-devel

Reply
Juan April 19, 2019 - 9:51 am

Not all steps, but when I want to enter softaculous, I get the following error

Site error: the ionCube PHP Loader needs to be installed. This is a widely used PHP extension for running ionCube protected PHP code, website security and malware blocking. Please visit get-loader.ioncube.com for install assistance.

Reply
Sandy April 20, 2019 - 7:37 pm

you can install ioncube loader via command line

Reply
duonghc May 23, 2019 - 9:09 am

Thank you for sharing.
I tried until step 2 and got this problem:
> yum-config-manager –enable remi-php72
Loaded plugins: fastestmirror

Could you give me a solution?
I also tried:
————
#rm -f /var/lib/rpm/__*
#rpm –rebuilddb -v -v
————
Or even
———–
/etc/yum/pluginconf.d/fastestmirror.conf
Change enabled=1 to enabled=0
———–

Thanks

Reply
duonghc May 24, 2019 - 1:36 pm

Hello!
After I clean and try this:
rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm

It’s ok now.
Thank you.

Reply
Igor August 7, 2019 - 11:24 am

HI,
CentOS Linux release 7.6.1810 (Core)
PHP 5.6.32

Do all steps from instruction with no errors
result: php -v
still PHP 5.6.32

Any ideas ?

Reply
Sandy August 8, 2019 - 6:38 am

Use the correct Remi repo

Reply
igor August 8, 2019 - 9:07 am Reply
Sandy August 8, 2019 - 6:18 pm

and what are the output for other commands ?

Reply

Leave a Comment