how to upgrade to php 7 in Ubuntu

how-to-upgrade-to-php7

how-to-upgrade-to-php7

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.
Next:

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:

php -v

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.

creating-indxphp-pagein-nano

creating-indxphp-pagein-nano


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.
just-updated-to-php7

just-updated-to-php7

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s