Today i am going to teach you how to install Php 7.2 its really easy to install and php 7 versions is really make your website amazing fast.You can install older versions of php just change the number of 7.2 to 7.0 or 7.1
Ubuntu 14.04, 16.04, 17.04, & 17.10:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2-cli
Debian 8 (Jessie) and 9 (Stretch)
sudo apt-get install apt-transport-https lsb-release ca-certificates
sudo 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" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt-get update
sudo apt-get install php7.2-cli
Web server configuration
Apache php-fpm
If you installed php7.2-fpm and if your using web server as Apache a2enconf php7.2 is going to make Apache use PHP 7.2 Type a2disconf php7.1-fpm to disable existing old version of php configurations
The steps would be similar for Nginx. Refer to the relevant documentation to change socket paths or IP:Port information.
Enable Apache mod_php
Disable the current PHP with a2dismod php7.1 make it enable new PHP 7.2 module with writing a2enmod php7.2
Remove old versions of php
(check phpinfo() , php --info), and remove the old version of Php
sudo apt purge php7.1*
How To Check Php Version ?
Write php -v in terminal and check the running version of php installed.İf its says php 7.2 its installed right and working with no issue
Source https://www.fetodoit.com/server/how-to-install-php-7-2-on-vps/