Downgrading PHP 5.4 to 5.3
In Ubuntu downgrading process is a really mess.
Here is the script which you could find it useful (it removes PHP 5.4 and install PHP 5.3):
sudo apt-get remove --purge `dpkg -l | grep php | grep -w 5.4 | awk '{print $2}' | xargs`
sudo apt-get install php5=5.3.10-1ubuntu3.4 php5-cli=5.3.10-1ubuntu3.4 php5-common=5.3.10-1ubuntu3.4 libapache2-mod-php5=5.3.10-1ubuntu3.4
sudo apt-get install php5=5.3.10-1ubuntu3.4 php5-cli=5.3.10-1ubuntu3.4 php5-common=5.3.10-1ubuntu3.4 libapache2-mod-php5=5.3.10-1ubuntu3.4
sudo apt-get install php-pear=5.3.10-1ubuntu3.4 php5-curl=5.3.10-1ubuntu3.4 php5-gd=5.3.10-1ubuntu3.4 php5-intl=5.3.10-1ubuntu3.4 php5-mysql=5.3.10-1ubuntu3.4 php5-pspell=5.3.10-1ubuntu3.4 php5-recode=5.3.10-1ubuntu3.4 php5-snmp=5.3.10-1ubuntu3.4 php5-sqlite=5.3.10-1ubuntu3.4 php5-tidy=5.3.10-1ubuntu3.4 php5-xmlrpc=5.3.10-1ubuntu3.4 php5-xsl=5.3.10-1ubuntu3.4
Where the available versions you can check by command: apt-cache showpkg php5
After the installation, verify it by command: php --version
Please be careful and don't install any other packages without package version specified (like php5-xcache), otherwise apt-get will replace your PHP instance with 5.4 again!
To prevent this happening, you can hold these packages.
Holding packages using dpkg
To hold packages by dpkg, you can execute the following command:
echo "php5 hold" | sudo dpkg --set-selections
To hold all PHP packages, run the following command:
dpkg --get-selections | grep ^php5 | sed s/install/hold/g | sudo dpkg --set-selections
The following command will show you holding status of your php packages:
sudo dpkg --get-selections | grep ^php
Holding packages using aptitude
You can also hold packages using aptitude e.g.:
sudo aptitude hold php5
Unhold:
sudo aptitude unhold php5
You could go with Ubuntu 10.04 Lucid. Security support runs out for that in less than a year, but that should give you enough time to patch your PHP.
In my opinion using an Ubuntu-supported package is preferable to compiling from source, and 10.04 does happen to have the version you want as its official package.
Eventually you are going to have to patch your PHP code, however. It shouldn't be that difficult to bring it into compatibility with later PHP versions: all issues will be well documented online, and there will only be a small number of issues that would affect backward compatibility. Older versions of PHP won't be supported forever and eventually you'll end up with security problems if you stick with PHP versions that are not officially supported.
Best Answer
I found this script on the ubuntu forums which worked for me
http://ubuntuforums.org/showthread.php?t=1566808
On ubuntu 10.10 you'll need to install
aptitude
as it is no longer installed by default.