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.

  1. Update the apt
    apt-get update
  2. 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
  3. Add the repository that is for php 7.2 its called ppa:/ondrej/php
    add-apt-repository ppa:ondrej/php
  4. Update the apt again after adding the repository
    apt-get update
  5. Now ready to install php 7.2 on ubuntu 16.04
    apt-get install php7.2
  6. Verify the php installation
    php --vesion

    sucessfully installed php 7.2 on ubuntu 16.04