vim /etc/apt/sources.list
and add these lines to it:
deb http://php53.dotdeb.org stable all
deb-src http://php53.dotdeb.org stable all
Download and import the dotdeb key:
wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | sudo apt-key add -
Then remove all php packages from the system. For example in my case:
apt-get remove php5 libapache2-mod-php5 php5-gd php5-mysql
apt-get remove php5-curl php5-tidy php5-dev php-pear php5-cli
apt-get remove php5-common php5-suhosin
Update your sources:
apt-get update
and reinstall PHP packages:
apt-get install php5 libapache2-mod-php5 php5-gd php5-mysql
apt-get install php5-curl php5-tidy php5-dev php-pear php5-cli
apt-get install php5-common php5-suhosin
now the following command will show you the new PHP version:
php -v
Update:
because php53.dotdeb.org no longer has lenny packages, we install the PHP 5.3 manually:
mkdir /tmp/php5
cd /tmp/php5
download all PHP5 packages from (our example is PHP 5.3.10) :
http://archives.dotdeb.org/dists/lenny/php5/5.3.10/binary-amd64/
wget -r -l 1 http://archives.dotdeb.org/dists/lenny/php5/5.3.10/binary-amd64/
remove old version:
apt-get remove php5 libapache2-mod-php5
apt-get remove php5-gd php5-mysql php5-curl
apt-get remove php5-tidy php5-dev php-pear
apt-get remove php5-common php5-mcrypt php5-cli
and install new PHP packages:
dpkg -i php5-common_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i libapache2-mod-php5_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5_5.3.10-1~dotdeb.0_all.deb
dpkg -i php5-mysql_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-curl_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-cli_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php-pear_5.3.10-1~dotdeb.0_all.deb
dpkg -i php5-curl_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-mcrypt_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-tidy_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-gd_5.3.10-1~dotdeb.0_amd64.deb
dpkg -i php5-dev_5.3.10-1~dotdeb.0_amd64.deb
restart the apache:
/etc/init.d/apache2 restart