Installing PHP 5.4 on Debian 6 (Squeeze)

Debian 7 (Wheezy) is due to come out soon, but I didn’t want to wait to upgrade to PHP 5.4, nor to install the release candidate. I tried using the Wheezy repository, but got dependency errors. Fortunately Dotdeb provides packages for Squeeze.

Set up Dotdeb

First add Dotdeb to your Apt sources:

sudo vim /etc/apt/sources.list

Add this to the end:

deb squeeze all
deb-src squeeze all
deb squeeze-php54 all
deb-src squeeze-php54 all

Save & exit, then run this to download the updates:

curl | sudo apt-key add -
sudo apt-get update

Install PHP 5.4

sudo apt-get dist-upgrade

Test it:

php -v

I found there were a couple of warning messages – I had to remove the old Suhosin & APC configuration files, and manually re-install APC:

sudo rm /etc/php5/conf.d/suhosin.ini
sudo rm /etc/php5/conf.d/apc.ini
sudo apt-get install php5-apc

Optionally install MySQL 5.5

If you get this message:

The following packages have been kept back:

It’s probably because Dotdeb includes MySQL 5.5 and Squeeze includes MySQL 5.1.

You can choose to upgrade with this command:

sudo apt-get install mysql-server

You may find phpMyAdmin gives a warning like this:

Your PHP MySQL library version 5.1.66 differs from your MySQL server version 5.5.30. This may cause unpredictable behavior.

You can fix this by installing the new MySQL Native Driver extension:

sudo apt-get install php5-mysqlnd