Has it happened to you, that you made an update and suddenly your programs using php are not working any more??? Well with this HOW TO you will learn how to downgrade php to an earlier version.
I have to say, this tutorial might work downgrading to any php version just with adjusting some parameters.
First lets begin with listing the php packages we have installed to make sure we have php 5.3
So in the console write:
dpkg -l | grep php
Search for the php version, it should say 5.3.x if so, then you are int he correct path ![]()
Now let’s add in /etc/apt/sources.list
nano /etc/apt/sources.list
and add the following:
deb ftp://ftp2.de.debian.org/debian/ lenny main contrib non-free deb-src ftp://ftp2.de.debian.org/debian/ lenny main contrib non-free
Now we will do something called pinning:
Create a file in /etc/apt/preferences.d and call it preferences
nano /etc/apt/preferences.d/preferences
Add in the file the following:
Package: php5* Pin: release a=oldstable Pin-Priority: 700 Package: * Pin: release a=stable Pin-Priority: 600
Now remove php with:
aptitude remove `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
then update and reinstall with old version:
apt-get update
apt-get -t oldstable install `dpkg -l | grep php5| awk '{print $2}' |tr "\n" " "`
Now check again to see if the old php version is installed doing again:
dpkg -l | grep php
Check if you have now php 5.2.x if so then everything is set!! Might be that you have to reboot your apache or your web server doing:
/etc/init.d/apache2 restart







September 13, 2012
i’have an error:
E: Package ‘libapache2-mod-php5′ has no installation candidate
E: Package ‘php5-cgi’ has no installation candidate
E: Package ‘php5-cli’ has no installation candidate
E: Package ‘php5-common’ has no installation candidate
E: Package ‘php5-curl’ has no installation candidate
E: Package ‘php5-gd’ has no installation candidate
E: Package ‘php5-idn’ has no installation candidate
E: Package ‘php5-imagick’ has no installation candidate
E: Package ‘php5-imap’ has no installation candidate
E: Package ‘php5-mcrypt’ has no installation candidate
E: Package ‘php5-memcache’ has no installation candidate
E: Package ‘php5-ming’ has no installation candidate
E: Package ‘php5-mysql’ has no installation candidate
E: Package ‘php5-ps’ has no installation candidate
E: Package ‘php5-pspell’ has no installation candidate
E: Package ‘php5-recode’ has no installation candidate
E: Package ‘php5-snmp’ has no installation candidate
E: Package ‘php5-sqlite’ has no installation candidate
E: Package ‘php5-suhosin’ has no installation candidate
E: Package ‘php5-tidy’ has no installation candidate
E: Package ‘php5-xmlrpc’ has no installation candidate
E: Package ‘php5-xsl’ has no installation candidate
September 13, 2012
@Giuseppe did you add the correct repo in /etc/apt/sources.list ?
December 1, 2012
Not working
after update it’s still 5.3.3
March 29, 2013
most probably you entered something wrong
May 13, 2013
No he’s not doing something wrong
The Lenny mirrors are down 
May 13, 2013
Wesley, you are 100% right! I forgot about that
May 31, 2013
Hi, i followed your guide to downgrade from wheezy to lenny.
Some remarks:
Use the archive repositories.
Use pin release a=lenny
Remove ibapache2-mod-php5 with –purge, so the configuration files are also remove, if not apache will not start.
Thank you,
December 12, 2013
Please rewrite your blog!
dpkg -l | grep php
mc -e /etc/apt/sources.list
deb http://archive.debian.org/debian/ lenny main
deb-src http://archive.debian.org/debian/ lenny main
mc -e /etc/apt/preferences.d/preferences
Package: php5*
Pin: release a=lenny
Pin-Priority: 700
Package: *
Pin: release a=stable
Pin-Priority: 600
aptitude remove `dpkg -l | grep php| awk ‘{print $2}’ |tr “\n” ” “`
apt-get remove libkrb53
apt-get install libkrb53
apt-get install apache2-mpm-prefork
apt-get -t lenny install `dpkg -l | grep php5| awk ‘{print $2}’ |tr “\n” ” “`
dpkg -l | grep php
apt-get install phpmyadmin
/etc/init.d/apache2 restart
Thanks!