How to install latest PHP 5.4.x on Ubuntu 12.04 LTS
1. Add this package-repository to your system. If Ubuntu says that you need to download a key first, then follow the instructions given in the notice.
sudo add-apt-repository ppa:ondrej/php5-oldstable
If you get an error message now, then please do an update first and install the python-software-properties, that need to be necessary to add a package repository:
sudo apt-get update sudo apt-get install python-software-properties
sudo apt-get update
Check the available version of PHP (the result is self-explaining, the version on the top is the one that will be installed):
apt-cache policy php5
3. Install PHP 5.4.x
sudo apt-get install php5
Check the installed version of PHP (if this does not show 5.4.x please restart your apache)
Please note: The ondrej/php5-oldstable repository (which is used here) provides the very latest version of the PHP 5.4-branch. Usually a version-update is available a few days after it was been officially released. This is really cool and a big step forward as Ubuntu, Debian, CentOS etc. provide only very old versions by default.