valentin vannay

valentincognito

Upgrade PHP version on Ubuntu

2016-11-10

If like me you always struggle when it comes to upgrade your PHP version here is a small on how to do it on ubuntu and the possible bugs and how to fix it.  

Upgrade your apt-get

sudo apt-get upgrade

Add Ondrej Sury's PHP PPA repo

More info here.
sudo apt-add-repository ppa:ondrej/php
If this gives you an error you might want to try to run this first:
sudo apt-get install software-properties-common python-software-properties
If you still have an error and it ressembles to this:

UnicodeDecodeError: 'ascii' codec can't decode byte 0x* in position *: ordinal not in range(128)"

Try the following commands:
sudo locale-gen en_US.UTF-8
export LANG=en_US.UTF-8
 

Update the package list and install the PHP version you want

sudo apt-get update
For PHP 5.5:
sudo apt-get install php5.5
For PHP 5.6:
sudo apt-get install php5.6
And PHP 7:
sudo apt-get install php7
  Et voila normally at this point if you run php-v you should see the new version ! If not don't hesitate to say it in the comments.