How to install php 5.4.4 (or newer version of 5.4) on ubuntu 12.04 LTS?

June 2, 2014 29.4k views
Using apt-get upgrade I can only get 5.3.10-1ubuntu3.11. The newest version of Moodle, Moodle 2.7 requires php 5.4.4 at least. I am looking to see how this is possible?
1 comment
3 Answers
To upgrade to a newer version of PHP 5.4 on Ubuntu 12.04, you can use Ondřej Surý's PPA. He is one of the Debian maintainers of the php5 package. See:

To use it, run:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
  • command ”add-apt-repository“ works only after:

    sudo apt-get install software-properties-common python-software-properties
Thanks for quick response.

I had to execute one other command for all of the rest of your commands to work, as the

add-apt-repository ppa:ondrej/php5

command did not work. So I looked this failure up on Stackoverflow and executed following command in addition

apt-get install python-software-properties

After which all went smoothly. My Moodle 2.7 installation on Ubuntu 12.04 using PHP (cli) (built: May 5 2014 09:32:44), (rest of LAMP same as parts of standard package) is now up and running.
Have another answer? Share your knowledge.