Experimental packages of PHP 5.4 for both Debian Squeeze and Ubuntu Natty are available over the damz.org repo
InstructionsExperimental PHP 5.4 packages for Debian/Ubuntu
Fetch the signing key:
curl http://apt.damz.org/key.gpg | sudo apt-key add -
Then update your source list:
# Debian Squeeze
deb http://apt.damz.org/debian squeeze php54
# Ubuntu Natty
deb http://apt.damz.org/ubuntu natty php54
And as usual:
apt-get update
apt-get install php5 php5-cgi libapache2-mod-php5 ...