Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to update to php 5.4 in Ubuntu 12.04, and I can only get 5.3.6 using official repositories (using apt-get).

I'm not really sure how to do a manual update – I'm sorta new to ubuntu, but I need to play around with the new php features!

share|improve this question
1  
if sudo apt-get upgrade Dont upgrade PHP then try sudo apt-get dist-upgrade. For distribution upgrade. –  Moiz Kiyani Oct 12 '13 at 16:19
add comment

2 Answers

up vote 158 down vote accepted

You could use a PPA to stay up-to-date with PHP. I use:

https://launchpad.net/~ondrej/+archive/php5 Launchpad logo

It's now on 5.5 and also includes Apache 2.4 update. For Apache 2.2+ PHP 5.4 repository, see the bottom of the answer.

If you want use this PHP, do this:

ppa:ondrej/php5 Launchpad logo (Click here for instructions on using PPAs.)

sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5

If you don't have add-apt-repository binary do the following:

sudo apt-get install python-software-properties

Precautions:

For Ubuntu 12.10

Ubuntu 12.10's official repository is updated to PHP 5.4. You should use the main repository package if you can. To do this, just install PHP5Install php5 without enabling any PPA.

PHP 5.4

Prepackaged latest PHP 5.4 now resides in separate PPA: ppa:ondrej/php5-oldstable Launchpad logo

share|improve this answer
4  
Turns out you gotta run sudo apt-get update first! –  kavisiegel Mar 5 '12 at 21:40
3  
there is the php5-cli package for that! –  matteosister Mar 7 '12 at 21:17
7  
After adding the ppa, you could do: sudo apt-get dist-upgrade –  matteosister Sep 23 '12 at 8:03
2  
After installing the ppa, upgrading php and running php -v, the version information starts with this error message: Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: cannot open shared object file: No such file or directory Annoying. –  systemovich Oct 24 '12 at 11:55
2  
that's normal. Php 5.4 uses a new version of the zend library. When you upgrade to 5.4 the xdebug extension gets recompiled. You need to check inside /usr/lib/php5 the name of the folder. Mine is 20100525, should be yours too, and check if there is a xdebug.so file. Now edit the xdebug.ini file in /etc/php5/mods-available/xdebug.ini (or the symlinked /etc/php5/conf.d/**-xdebug.ini) and set the correct path to the xdebug.so file –  matteosister Oct 24 '12 at 15:14
show 12 more comments

It will take some time for PHP 5.4 packages to make their way into Ubuntu, as there are an awful lot of dependency checks to do. Ubuntu 12.04 is now in beta so I doubt they'll upgrade it to PHP 5.4 (although I have no official or inside knowledge of this) -- it probably won't appear until Ubuntu 12.10 in October this year. If you want it sooner than that, you'll either have to find a third-party package or learn to build it yourself from the source code.

share|improve this answer
add comment

protected by Community Jan 28 at 17:41

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.