Having used dotdeb.org packages for years (a huge thanks is appropriate here), package maintainer Guillaume Plessis recently announced he would stop providing PHP packages, instead suggesting to switch to the PPA packages provided by Ondrey Sury.
As I was running DotDeb PHP7.0 packages, I first looked at switching to the Sury packages on Debian 8.
apt-get install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
This adds the repository to your Debian installation, allowing the use of apt to install the packages it provides.
At the time of writing, this includes separately installable packages for php7.0 and php7.1.
Next, simply perform an update with apt
sudo apt update
Apt overwrites the dotdeb packages with those from the Sury repository rapidly, and perfectly. As I chose to keep my existing php.ini file, things worked out of the box without other changes.
Next up, you can safely remove dotdeb repository (at least if you’re not using it for anything else anymore). Just comment out or remove the lines from /etc/apt/sources.list that point to dotdeb.
Install PHP 7.1
Now that the repository is added and tested via PHP7.0, installing PHP7.1 is a piece of cake:
sudo apt install php7.1 php7.1-fpm php7.1-mysql php7.1-mbstring php7.1-curl
You may need to install more packages (you can list all of them via ‘apt-cache search php7.1’), but this is basically my starter package.
After installation, PHP gets installed under /etc/php/7.1 . You can test via the command line if things are installed properly via:
# php7.1 -v PHP 7.1.1-1+0~20170120094658.14+jessie~1.gbp69d416 (cli) (built: Jan 20 2017 11:53:59) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.1-1+0~20170120094658.14+jessie~1.gbp69d416, Copyright (c) 1999-2017, by Zend Technologies
While you can continue to change handlers in nginx, apache or whatever webserver you’re going to use, you could also add this handler to Plesk, if you’re running that as well.
Thanks to their useful documentation, this turns out to be easy as well.
plesk bin php_handler --add -displayname "7.1 by deb.sury.org" -path /usr/bin/php -clipath /usr/bin/php7.1 -phpini /etc/php/7.1/fpm/php.ini -type fpm -service php-fpm7.1 -poold /etc/php/7.1/fpm/pool.d -id 71fpm
Note that in the above command, I’m providing a custom Id for the handler, avoiding Plesk to generate a long hash, making it difficult to modify your handler via its Id if you want to later on.
I was left to simply change the PHP handler for my site via the Plesk control panel, and things were working as smooth as ever!