在CentOS7上将PHP从5.5.7更新到7.

I tried many times to update PHP from 5.5 to 7 on CentOS 7 but always unsuccessful. The installation seems always going well but when I checked php-v it is always:

PHP 5.5.7 (cli) (built: Jul  5 2017 12:03:23)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend Guard Loader v3.3, Copyright (c) 1998-2014, by Zend Technologies

Any idea how can I update?

Base repository of CentOS has no php7 packages.
You can use remi repo to install php7 on your CentOS 7.

Why Remi?

  • PHP package installed from remi repo will work as drop-in replacement for your current php5 binaries.
  • Remi repo is managed by one of PHP internals
  • Why not?

To install the Remi repository, we need to enable the EPEL repository first.

sudo yum install epel-release yum-utils
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Then Enable php 7.0 (You can use php 7.1+ too)

sudo yum-config-manager --enable remi-php70

Now it's time to install php7

yum install php php-common php-cli php-mysql

Great!!!
Now you have php7 on your system. You can confirm with :

php -v

Details Instruction on how to setup php on different OS : https://rpms.remirepo.net/wizard/