For the time being, we need PHP 5.2 on some of our servers. From version 10.04 Lucid Lynx, Ubuntu started shipping PHP 5.3. I found info on how to install PHP on Lucid by using the packages from the previous version of Ubuntu, 9.10 Karmic Koala.
However, those packages are no longer online, Karmic is long past end of life. The only currently supported release that still has PHP 5.2 is 8.04 Hardy. I was able to get PHP 5.2.4 installed (eventually) using the packages from hardy.
sudo apt-get install apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5 php5-cli php5-common php5-curl php5-gd php5-mcrypt php5-mhash php5-mysql
I constructed the two files mostly from things I read about how to get packages from Karmic to install on Lucid. YMMV.