Install PHP on Ubuntu 16.04

List all php packages installed:

dpkg -l | grep php| awk '{print $2}' |tr "\n" " "

Remove all php package:

sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`

Add PPA

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6

You can install php5.6 modules too for example

sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml

Verify your version

sudo php -v

Leave a Reply

Your email address will not be published. Required fields are marked *