PHP5.6 (or higher) on Ubuntu 14.04

Ubuntu 14.04’s official repo isn’t going to support PHP 5.6 or above. I’m currently on v5.5.9-1 and needed to move to a higher version for a Symfony PHP app I’m working on.

Most googling shows you the outdated answer so here’s the commands that worked for me.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6 libapache2-mod-php5.6 php5.6-mcrypt php5.6-json php5.6-mysql php5.6-curl php5.6-xml php5.6-soap php5.6-zip php5.6-gd php5.6-mbstring php5.6-intl php5.6-bcmath

The old commands on the net suggest using sudo add-apt-repository ppa:ondrej/php5-5.6 but that package is deprecated.

If you run

apt-cache search php | grep -E 'php[0-9\.]+ -'

you’ll see that you can install php5, php5.5, php5.6, php7.0 and php7.1 (as at the time of writing – September 2016).

If you only want to see the php 5.6 packages and modules available you can run  apt-cache search php | grep 5.6  or change the grep to different versions as applicable.

php5-6

Hopefully this helps some people.

Update : I can’t seem to find the xdebug module for any version of PHP in the ppa:ondrej/php repository. Not in php 5.6 nor 7.1 and between. If you want to do local development then you might be best upgrading to Ubuntu 16.04 which comes with php7 by default, although note they only call it php in the apt repo, so you might have to update your Ansible config, assuming you are using Ansible, Puppet, Chef or some other server orchestration system.

Cheers!

By Michael Kubler

Photographer, cinematographer, web master/coder.

Leave a comment

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