Step 1
aptitude 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 &&
aptitude update
Step 2
aptitude install php7.2-cli
aptitude install php7.2-fpm
aptitude install php7.2-bcmath
aptitude install php7.2-mysql
aptitude install php7.2-curl
aptitude install php7.2-gd
aptitude install php7.2-imagick
aptitude install php7.2-intl
aptitude install php7.2-mbstring
aptitude install php7.2-xmlrpc
aptitude install php7.2-xsl
aptitude install php7.2-dev
aptitude install zip php7.2-zip
aptitude install php-pear
aptitude install php7.2-soap
aptitude install php7.2-xml
pecl install timezonedb
aptitude install libmcrypt-dev libreadline-dev
pecl install mcrypt-snapshot
How to fix «mcrypt.h not found. Please reinstall libmcrypt» in Debian 9?
Step 3
rm -rf /etc/php/7.2/cli &&
ln -s /etc/php/7.2/fpm /etc/php/7.2/cli &&
/etc/init.d/php7.2-fpm restart
Step 4
apt-get purge php7.1-common php7.1-cli php7.1-fpm