TRY:
Update your respositories:
sudo apt-get update
Download and install from respositories:
sudo apt-get install php5 php5-common php5-cli php5-dev php5-mysql phpmyadmin php5-pgsql phppgadmin php5-gd php5-mcrypt php5-curl php-pear libapache2-mod-php5 php5-xdebug php5-codesniffer
ALTERNATIVE:
Download PHP5.3.10 from here:
5.3.10-1unbuntu3.15: http://packages.ubuntu.com/precise-updates/i386/php5-gd/download
5.3.10-1unbuntu3.14: https://launchpad.net/ubuntu/precise/i386/php5-gd/5.3.10-1ubuntu3.14
To Install:
ubuntu3.14 version: dpkg -i php5-gd_5.3.10-1ubuntu3.15_i386.deb
ubuntu3.15 version: dpkg -i php5-gd_5.3.10-1ubuntu3.15_i386.deb
If you get any errors configuring, depending on error you have to install dependencies:
http://zgadzaj.com/how-to-install-php-53-and-52-together-on-ubuntu-1204
Consider looking this article about PHP Downgrades:
How to downgrade from PHP 5.4 to 5.3
Good Luck!