It’s a very hot-knob technique and takes not more than few minutes.
Recently I’ve installed and re-installed Windows and Ubuntu – side by side (please don’t consult Urban Dictionary to find the latest meaning of this old fashioned phrase, you’ll be shocked).
It was quite natural that Ubuntu sits on my home machine with old php version, that is, php 5 point something.
I’ve fixed with few simple commands that you may try while doing the same side-by-side :).
Open your terminal and paste:
sudo apt-get update
It shouldn’t take more than dew seconds if you have a good internet speed.
sudo add-apt-repository ppa:ondrej/php
Okay, at this stage you may face a warning that the suitable language pack is not there. You can fix it quite easily with two commands – side by side 🙂
sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
Next come the main event:
sudo apt-get install php7.0
It’ll upgrade your php to 7. And you must make the bindings with MySQL. So run this command after that:
sudo apt-get install php7.0-mysql
Check your php version with this one:
It’ll produce this output:
PHP 7.0.27-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Jan 11 2018 23:19:41) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.27-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
That’s it! You have successfully upgraded to php 7.
Now go to /var/www/html and create an index.php file inside with the help of nano text editor.
Move the index.html to a new directory if you have a sensitive mind of having not-to-kill-a-file.
Type localhost in your browser and you’ll see the output, I have just written in my nano.