‘Clean’ upgrade to PHP 7.* (CentOS/Debian/Ubuntu)

Earlier this year, I wrote a short article: 80% of the Web Powered by PHP. Also, it was noted in the article that over 90% of PHP based websites are Still using PHP 5, This is true even today. However, it must be said that, over the past 6 months, there have been more upgrades to PHP 7 than to PHP 5.6. So progress is slow, though slow. Some of the factors preventing mass upgrades to PHP 7 are correspondingly, the lack of PHP 7 support built in by Linux distros and perhaps some not fully aware of. PHP 7 efficiency gains,

The easy part is tracking which lines of code are not PHP 7 ready. you can do it with PHP7cc, php7cc is a command line tool designed to ease migration from PHP 5.3-5.6 to PHP 7 by searching your existing code and generating a report containing the filename, line number and description of each incompatibility issue. Using it is as easy as: PHP7cc is no longer supported, use one of these PHP compatibility checking methods instead. The following upgrade instructions will replace PHP instead of installing individual versions…

CentOS 6: Upgrade to PHP 7

Add for a Clean In-Place Upgrade to PHP 7 on CentOS 6 EPEL And remy inventory:

yum install 
yum install 

to establish yum-utils,

yum install yum-utils

Select which version of PHP 7 you want:

yum-config-manager --enable remi-php71

or one of these:

yum-config-manager --enable remi-php70
yum-config-manager --enable remi-php72

Upgrade PHP 7.

yum update

CentOS 7: Upgrade to PHP 7

Add for a Clean In-Place Upgrade to PHP 7 on CentOS 7 EPEL And remy inventory:

yum install 
yum install 

to establish yum-utils,

yum install yum-utils

Select which version of PHP 7 you want:

yum-config-manager --enable remi-php71

or one of these:

yum-config-manager --enable remi-php70
yum-config-manager --enable remi-php72

Upgrade to PHP 7.

yum update

Debian 8/9: Upgrade to PHP 7

add Sun’s PHP repository,

sudo apt-get install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg 
sudo echo "deb  $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list

Upgrade to PHP 7:

sudo apt-get update && sudo apt-get upgrade

Ubuntu 14 to 16: Upgrade to PHP 7

add of the sun Personal Package Archives (PPA,

sudo add-apt-repository ppa:ondrej/php

Upgrade to PHP 7:

sudo apt-get update && sudo apt-get upgrade

Access PHP 7 without adding a repository

For Debian/Ubuntu, if you are a little careful using deb.sury.orgOf course, you can upgrade your distribution to Ubuntu 16 or Debian 9 instead. Both support PHP 7.0 (not 7.1+). Add suggestions other than compiling below.

Edit: See also for CentOS 6/7 php. correct repo for, (Thank you @godman_8,

Leave a Comment