I’m Paul Herron, a full-stack developer and technical manager.
I focus mainly on back-end development with tools like Symfony
and devops with tools like Docker

Installing PHP 5.4 on Ubuntu 12.04

by Paul Herron on 25 May 2014

Just a quick one from me today.

The other day I was working on a project at MBA & Company that required some of the new language features offered by PHP 5.4. As such, the default PHP 5.3 that gets intalled by apt-get wouldn’t do.

Happily there’s a nice personal repository by Ondřej Surý that makes 5.4 really easy to install. I don’t think a PPA would be an ideal situation for a production server (compiling from source would probably be a better option there) but as I’m just running this on a virtual development machine I’m happy to go with it.

The names of these packages are a bit of a moving target. At the time of writing PHP 5.4 is labelled as php5-oldstable, so that’s the one we’ll use. Here are the steps to get it working:

sudo apt-get update

# This package might seem unrelated but it gives the ability to run 'add-apt-repository'.
sudo apt-get install python-software-properties

add-apt-repository ppa:ondrej/php5-oldstable
apt-get update

# Install the relevant PHP5 packages for you, for example:
apt-get install php5-fpm php5-cli php5-cgi

Back to homepage Back to blog listing