24

Im setting up a vps for the first time from scratch, the host has a one click LAMP installer which took out allot of the leg work, but running phpinfo(); i found im running 5.3.10.

So id like to update it to 5.4.10 - Ive run sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt but it says php5 is the latest version, any ideas about how to update this ?

The server is running Ubuntu 12.04

sam
  • 313
  • 1
  • 2
  • 7
  • Although I provided an answer, why do you specifically want 5.4.10? 5.3.x in 12.04 tend to get security updates still so any CVEs or security issues between 5.3.x and 5.4.10 are usually fixed... – Thomas Ward Sep 09 '13 at 23:40

3 Answers3

34

PHP 5.4.10 is not available in the Ubuntu repositories for 12.04.

You have two options:

(1) try and find a PPA with a backported version of PHP 5.4.10 (such as ondrej's oldstable PPA)

a) Run this command: sudo apt-get install python-software-properties
b) Run this command: sudo add-apt-repository ppa:ondrej/php5-oldstable
c) Run sudo apt-get update; sudo apt-get install php5
d) This should allow you to use PHP 5.4.10 (or whatever the most recent "Old Stable PHP" is).

(2) download PHP from source, and compile it.

5.4.10 does not exist in the repositories for any version of Ubuntu, apparently, so you're stuck with these two options for all releases.

(I can try and backport 5.4.10 from Debian if you would like, but it would be in a PPA, so you'd have to trust that I'm not giving you malware, although I wouldn't do that ever.)

Thomas Ward
  • 72,494
  • 30
  • 173
  • 237
  • Thanks @Thomas W - looking back at the php.net downloads it seems the last stable version of 5.4 was 5.4.19 is that easier to install seeing as its the current Old stable ? – sam Sep 10 '13 at 09:47
  • @sam No, that's no easier to install than 5.4.10, as it is not in the repositories and would need to be put into a PPA or compiled from source to be installed. – Thomas Ward Sep 10 '13 at 14:37
  • 2
    Thanks @Thomas W - i actually ended up getting to work using `sudo add-apt-repository ppa:ondrej/php5-oldstable` which installed 5.4.19 - taken from [HERE](http://serverfault.com/questions/420286/how-do-i-upgrade-from-php-5-3-to-php-5-4-6-in-ubuntu) – sam Sep 10 '13 at 19:23
  • @sam Yeah, ondrej's PPA is decent, I'll also add that data here. – Thomas Ward Sep 11 '13 at 01:51
  • Thanks - i think an important point to add is that you also need to have run apt-get install python-software-properties to be able to use add-apt-repository – sam Sep 11 '13 at 08:37
  • Also just a note `sudo add-apt-repository ppa:ondrej/php5-oldstable` installed 5.4.19 at time of writing rather than 5.4.10 – sam Sep 11 '13 at 09:57
  • @sam updated that too. Note you should be able to propose edits to questions/answers, and you're free to do so. – Thomas Ward Sep 11 '13 at 14:18
  • http://pastebin.com/SpHVfd7r is what happens to me when I try to add the repo :? – James Heald Jul 03 '14 at 15:46
  • @jamertheprogrammer don't copy paste that command, try typing it out. looks like there might be stray ASCII in the command when you paste it in. – Thomas Ward Jul 03 '14 at 19:06
2

Installing PHP 5.4.* on Ubuntu 12.04 Simply add the PPA repository:

sudo add-apt-repository ppa:ondrej/php5-oldstable

And install it:

sudo apt-get update
sudo apt-get install php5
Kamlesh Kumar
  • 271
  • 1
  • 2
  • 8
0

You don't need to add repositories. Simply use these steps:

  1. sudo add-apt-repository ppa:ondrej/php5-oldstable
  2. sudo apt-get update
  3. sudo apt-get install php5

that's it.