HOW TO: Downgrade php 5.3 to 5.2 in Debian


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



JOIN OUR NEWSLETTER

Join my newsletter for FREE! Be one of thousands of people that receive ONE mail per week with the coolest posts of the week! JUMP IN don't be shy!!

We hate spam. Your email address will not be sold or shared with anyone else.

Author: Rocko

Share This Post On

8 Comments

  1. 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

    Post a Reply
    • @Giuseppe did you add the correct repo in /etc/apt/sources.list ?

      Post a Reply
  2. Not working :( after update it’s still 5.3.3

    Post a Reply
  3. No he’s not doing something wrong :) The Lenny mirrors are down :P

    Post a Reply
  4. 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,

    Post a Reply
  5. 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!

    Post a Reply

Leave a Reply / Comment / Opinion :)

%d bloggers like this: