The way we install php are almost same for all the versions, the only difference will be on the repository. The php version 7.2 will have its own apt repository from where we will fetch it for installation. If the version differs you have to look for the respective repository.
steps to install php 7.2 on ubuntu 16.04
Follow the following steps to install php 7.2 on ubuntu 16.04.
- Update the apt
- Install the package which will help us adding the repository. These steps might not require if you have already installed it
apt-get install software-properties-common
- Add the repository that is for php 7.2 its called ppa:/ondrej/php
- Update the apt again after adding the repository
- Now ready to install php 7.2 on ubuntu 16.04
apt-get install php7.2
- Verify the php installation