Suppose you have apache 2 server installed in your Ubuntu 14 and it came with php 5*. Now whenever you start apache 2 server typing localhost in your browser, you find that your apache server has not been configured with php 7.1.
Now how you’d solve this nagging problem?
First you need to remove every php version from your machine.
sudo apt-get purge php.*
Next you need to reinstall PHP 7 by these commands one after another:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1
sudo apt-get install php7.0-mysql
sudo apt install php libapache2-mod-php
sudo apt install php7.0-mbstring
It’s done. Now your apache server has been configured with php latest version.