How to install/setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2 (and how to fix the GPG key error)

Please note: This works fine. But this package will also upgrade your apache to version 2.4 which has different config files than apache 2.2 and even deletes stuff, like /etc/apache2/sites-available/default when upgrading. This may result in a loss of your apache settings (vhost, mod_rewrite stuff etc.). Be aware of that ! This shit cost me a full weekend. :(
This affects only upgrades, not fresh installs for sure.
Update on that issue: This is a known bug, I’ll keep this post updated…
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=716880
There’s a nice method to install the very latest version of PHP 5.5 on Debian Wheezy 7.0 or 7.1 with some bash commands.
1. Add these package sources to your sources.list file: Enter the file via
sudo nano /etc/apt/sources.list
and add these lines at the end of the file (right click pastes):
deb http://packages.dotdeb.org wheezy-php55 all deb-src http://packages.dotdeb.org wheezy-php55 all
Save and close (CTRL-X, “y”, ENTER).
2. Do an update:
sudo apt-get update
You’ll get an error message in the last line of the update progress now.
3. It’s not possible to install PHP now, as Debian just gave an error and said that these new sources are not verified and blah blah, the public key is not available… I find this process highly unintutive and I really don’t know why it’s so complicated to update PHP, but well, that’s how it is…
Method #1
The last line of this error message contains a key, like “E9C74FEEA2098A6E”. Copy that key (mark the string with the mouse usually copies it into the clipboard) and run these commands to verifiy the new package sources (and put YOUR key in here):
gpg --keyserver packages.dotdeb.org --recv-key E9C74FEEA2098A6E gpg -a --export E9C74FEEA2098A6E | sudo apt-key add -
Method #2 (thanks Petr for bringing this in!)
wget http://www.dotdeb.org/dotdeb.gpg sudo apt-key add dotdeb.gpg
4. Do an update again:
sudo apt-get update
5. Install the latest version of PHP 5:
sudo apt-get install php5
6. Check the installed version of PHP 5 (phpinfo() will still show old PHP version until apache restart):
php -v
Finally, restart the apache:
sudo service apache2 restart
By the way, it’s not possible (as far as I know) to install PHP 5.5 on Debian 6 (without compiling source code manually).
By the way #2, I’ve also written a tutorial on “How to setup latest version of PHP 5.5 on Ubuntu 12.04 LTS“, which is different from this here.
gpg: directory `/home/vagrant/.gnupg’ created
gpg: new configuration file `/home/vagrant/.gnupg/gpg.conf’ created
gpg: WARNING: options in `/home/vagrant/.gnupg/gpg.conf’ are not yet active during this run
gpg: keyring `/home/vagrant/.gnupg/secring.gpg’ created
gpg: keyring `/home/vagrant/.gnupg/pubring.gpg’ created
gpg: requesting key A2098A6E from hkp server packages.dotdeb.org
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error
Dont forget enable php5 extension in apache, else you will see sources of your files – not a php .
Nick
Thanks,was helpful
Dont try this on production… :S
Sure, nobody should change major versions of anything on production while being live + public!
How to undo this changes? My old Laravel 4.2 app not work (BladeCompiler error with preg_replace_callback(): Compilation failed: internal error: previously-checked referenced subpattern not found at offset 47)
This article was all I needed, thank you very much!
Nice , and worked for me.
this package will also upgrade your apache to version 2.4
After following the instructions, my Apache remained v2.2.22 even though PHP is now 5.5.19-1
Is that ok?
I have followed this instructions to upgrade php 5.4 to 5.5 in Debian 7.5 and the Apache was not upgraded to 2.4 .
It seems that Debian is not supporting yet Apache 2.4 in the stable version or i am wrong?
Nice tutorial :)
This works perfectly. Btw, the tutorial is for 7.0/7.1, not 7.5
atfer doing steps in your manual and apt-get upgrade following message:
The following packages have been kept back:
php-pear php5-cgi php5-cli php5-common php5-curl php5-dev php5-fpm php5-gd php5-intl php5-mcrypt php5-memcache php5-mysql php5-xmlrpc php5-xsl
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
the “gpg” commands here did not work for me – there are different instructions (http://www.dotdeb.org/instructions/) on dotdeb.org website about adding their public repository key – those worked for me:
wget http://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
Hey Petr, that’s interesting, as I have “my” install instruction from exactly the same site. Anyway, thanks for the feedback, I’ll put this into the article.