Installing old versions of PHP in modern OS can be tricky. Here is my instruction about how to install PHP 5.3 on Ubuntu 14.04.
Prepare
Become a root
sudo su
Optionally – generate locale files. That can be useful if you have non-english default localization
locale-gen en_US.UTF-8
Remove old PHP and Apache
Check out your current PHP packages list
dpkg -l|grep php
Backup old configs
cp -R /etc/php5 /etc/php5_old cp -R /etc/apache2 /etc/apache2_old
Remove all current PHP packages and apache2 package as well
apt-get purge place-here-all-php-packages-found-in-previous-step-devided-by-space apache2
Installing new PHP and Apache
Switch to another repository
sed -i.bak "s/trusty/precise/g" /etc/apt/sources.list apt-get update
Install necessary packages
apt-get install apache2 php5 libapache2-mod-php5 apache2-mpm-itk libapache2-mod-rpaf php-pear php5-gd php5-mysql php5-common php5-curl php5-cli apache2.2-common php5-xdebug
Optionally – prevent installed packages from updating with apt-get upgrade command
apt-mark hold apache2 php5 libapache2-mod-php5 apache2-mpm-itk libapache2-mod-rpaf php-pear php5-gd php5-mysql php5-common php5-curl php5-cli apache2.2-common php5-xdebug
Revert back repository config
sed -i.bak "s/precise/trusty/g" /etc/apt/sources.list
Reboot your machine and check PHP version with command
php -v