Login to your Ubuntu server with root user with your favorite SSH client
Let’s first update the operating system with all the latest packages with the command
sudo apt-get update
Since PHP 7 is not available for Ubuntu Trusty in the standard Ubuntu repositories , we first need to install PPA called ondrej/php with the command.
sudo add-apt-repository ppa:ondrej/php
Press enter button to continue
Now we can list the all the available PHP 7 packages with the command
apt-cache search php7
Let’s install PHP 7 with some of its required modules with the command
sudo apt-get install php7.0 php7.0-cli php7.0-fpm php7.0-gd php7.0-json php7.0-mysql
Wait for few in order to complete the installation and in order to check if the PHP is installed correctly use the command as and you should see the output as below
php –v