Upgrading to PHP 7.x (7.0 or 7.1 as of the time of this writing) is just as easy as it is to upgrade to PHP 5.6!
Before we install PHP 7.x, I would recommend getting your system up to date:
Next you will need to add the deb.sury.org PPA:
add-apt-repository isn’t found, you can install it by way of the
Once you get the PPA added, you’ll want to do an update so the packages show up:
At this point, you can install PHP 7.x and any extensions you may want.
Scary Warning: Installing the
php7.x packages will install Apache, even if
you have another web server already installed. This is just how the meta package
is setup. You can install
php7.x-fpm directly without
installing Apache. If you do end up installing Apache and don’t want or need it,
just uninstall it.
At this point, you should have PHP 7.x up and running on your server!
Once installed, you will want to restart your web server and your fast process manager (if you use one) and you should be good to go!
One additional note, the PPA I mentioned in this article is provided free of charge by Ondřej Surý. The PPA may be free, but his time maintaining it is not. Please consider donating if you found this article or his PPA useful.