Installing PHP 5.4 in Ubuntu

I’ve been excitedly awaiting some of the new features found in PHP 5.4, in particular array notation and file upload progress monitoring so I decided to try and install PHP 5.4 on Ubuntu. Fortunately there is a repository of prebuilt packages for Ubuntu.

I recommend using a VM so you don’t mess up any stable PHP install.

Update

Since writing this post php 5.4 stable has been released and a more up to date package is available in this ppa: https://launchpad.net/~ondrej/+archive/php5 I haven’t tested this personally but should work as described below.

Installation

The ppa can be simply added to ubuntu:

sudo add-apt-repository ppa:ondrej/php5

Then installing as normal

sudo apt-get update
sudo apt-get install php5 libapache2-mod-php5