HOW TO: Downgrade php 5.3 to 5.2 in Debian

[social_share style=”circle” align=”horizontal” heading_align=”inline” facebook=”1″ twitter=”1″ google_plus=”1″ linkedin=”1″ pinterest=”1″ /]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:

[code]dpkg -l | grep php[/code]

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

[code]nano /etc/apt/sources.list[/code]

and add the following:

[code]deb lenny main contrib non-free
deb-src lenny main contrib non-free[/code]

Now we will do something called pinning:

Create a file in /etc/apt/preferences.d and call it preferences

[code]nano /etc/apt/preferences.d/preferences[/code]

Add in the file the following:

[code]Package: php5*
Pin: release a=oldstable
Pin-Priority: 700

Package: *
Pin: release a=stable
Pin-Priority: 600[/code]

Now remove php with:

[code]aptitude remove `dpkg -l | grep php| awk ‘{print $2}’ |tr “\n” ” “`[/code]

then update and reinstall with old version:

[code]apt-get update
apt-get -t oldstable install `dpkg -l | grep php5| awk ‘{print $2}’ |tr “\n” ” “`[/code]

Now check again to see if the old php version is installed doing again:

[code]dpkg -l | grep php[/code]

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:

[code]/etc/init.d/apache2 restart[/code]

[social_share style=”circle” align=”horizontal” heading_align=”inline” text=”” heading=”” facebook=”1″ twitter=”1″ google_plus=”1″ linkedin=”1″ pinterest=”1″ link=”” /]

Author: Rocko

Share This Post On