On the Ubuntu 10.04 Lucid Lynx release, by default PHP 5.3 is installed. Great if you are using it, but it's not for everyone. Definitely not for me being a Drupal developer, as for the moment, it causes problems.
This method worked for me (however I am not responsible if it doesn't for you). All you need to do it put this lot in a shell file and run it. Remember to
chmod +x file for it to run.
php_packages=`dpkg -l | grep php | awk '{print $2}'`
sudo apt-get remove $php_packages
sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list
sudo mkdir -p /etc/apt/preferences.d/
for package in $php_packages;
do echo "Package: $package
Pin: release a=karmic
Pin-Priority: 991
" | sudo tee -a /etc/apt/preferences.d/php
done
sudo apt-get update
sudo apt-get install $php_packages
sudo /etc/init.d/apache2 restart