Wednesday, March 16, 2011

Downgrading from PHP 5.3 to 5.2 on Debian Squeeze

Problem

You've installed PHP 5.3 on your Debian Squeeze system. Problem is, some web apps have trouble running on that version. You need to downgrade your system from 5.3 to 5.2.

Solution

Remove the PHP 5.3 packages from your system:
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
Clean the cache just to be sure:
rm -f /var/cache/apt/archives/php5*
Use Karmiс for PHP packages:

echo -e "Package: php5\nPin: release v=karmic\nPin-Priority: 991\n" | sudo tee /etc/apt/preferences.d/php > /dev/null
apt-cache search php5-|grep php5-|awk '{print "Package:", $1,"\nPin: release v=karmic\nPin-Priority: 991\n"}'|sudo tee /etc/apt/preferences.d/php > /dev/null
Add Ubuntu Karmic to source list:

cd /etc/apt/sources.list.d
sudo wget -O karmic.list "http://pastebin.com/download.php?i=q9ya307g"
(Update, October 18, 2012: The sources list has been updated, because Ubuntu no longer supports Karmic. Please leave a comment if this still doesn't work.)

Update the package database:
sudo apt-get update
If the command above produces this error:

W: GPG error: http://security.ubuntu.com karmic-security Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5
W: GPG error: http://archive.ubuntu.com karmic Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5
W: GPG error: http://archive.ubuntu.com karmic-updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5
Then import the required keys and add them to your list of trusted keys:

gpg --keyserver hkp://subkeys.pgp.net --recv-keys 40976EAF437D05B5
gpg --export --armor 437D05B5 | sudo apt-key add -

gpg --keyserver hkp://subkeys.pgp.net --recv-keys 40976EAF437D05B5
gpg --export --armor 40976EAF437D05B5 | sudo apt-key add -

gpg --keyserver hkp://subkeys.pgp.net --recv-keys 40976EAF437D05B5
gpg --export --armor 40976EAF437D05B5 | sudo apt-key add -
Finally, install PHP 5.2:
sudo apt-get install -t karmic php5-cli php5-cgi libapache2-mod-php5
UPDATE: Using the Ubuntu sources to download old packages works on Debian. So far, it works on my system, but you may need to use the Debian sources just in case.

14 comments:

Anonymous said...

thanks

matthias said...

worked fine, thanks!

simoncpu-test said...

It looks like Karmic is no longer supported by Ubuntu, as it's not an LTS (Long Term Support) release.

I've updated the source list to point to the old releas server:

http://pastebin.com/download.php?i=q9ya307g

Anonymous said...

with purge I have
The following packages will be REMOVED:
libapache2-mod-php5{p} libonig2{u} libqdbm14{u} php5-cli{p}
php5-common{p} php5-mysql{p} php5-suhosin{p}

I maked a fresh installation of debian squeeze;

for curiosity
is necessary purge all?
I read this
libapache2-mod-php5 5.3.3-7+squeeze14
php5-cli 5.3.3-7+squeeze14
php5-common 5.3.3-7+squeeze14
php5-mysql 5.3.3-7+squeeze14
php5-suhosin 0.9.32.1-1 advanced protection module for php5
libapache2-mod-php5

must purge all?also libonig2{u} libqdbm14{u}? ok not are installed but are php 5.3?

I found oneother solutions

... But I also added:

deb http://packages.dotdeb.org lenny all
deb-src http://packages.dotdeb.org lenny all


And.. I had to install the packages with the version specified. On http://www.debian-database.org/ you can find all the version of the packages.

I installed PHP 5.2.17 with the following commands:
# sudo apt-get -t stable install php5-cli=5.2.17-0.dotdeb.0
...

is correct this solution?

Anonymous said...

I does your solution but installed all php 5.3.3-7+squeeze14



Anonymous said...

not work install php 5.3.3

Anonymous said...

I found that
Karmic was EOLed back in April. The packages are no longer available.
is so?

and is possible instead not a standard repo url but old repo http://old-releases.ubuntu.com/ubuntu

but hoe can to use in your code?

simoncpu-test said...

Yepp, it's EOL'd already... I've updated the source list to point to the old repo... It's at http://pastebin.com/download.php?i=q9ya307g

If this still doesn't work, you can try asking around at ##linux and #debian via Freenode IRC server (irc.freenode.net). =)

simoncpu-test said...

BTW, please don't forget to purge your cache and do a sudo apt-get update after you've downloaded the source list.

Anonymous said...

I will repeat all the steps;

one clarification
now you post that:

"I've updated the source list to point to the old repo ..."

and in the initial post March 16, 2011 you post
wget -O karmic.list "http://pastebin.com/download.php?i=q9ya307g"

the two links are identical;so you
have access at the pastebin.com site and changed something inner the site?

simoncpu-test said...

Hi, The link "http://pastebin.com/download.php?i=q9ya307g" is the new updated link that I've made on October 18, 2012. It contains link to the repo for old packages.

Anonymous said...

/var/cache/apt/archives
I noticed that now in this folder there are the 5.2.10 deb;
in future I can use this for install
php 5.2.10 in other server?
so not more important to connect at the repository?

if yes which is the link for download all the php 5.2.10 .deb packages ?





Anonymous said...

clarification
I read that for remove old packages there are this commands:
remove the installation
purge = remove installation and configuration
autoremove clear also the dependance


when is better use one or another?

Anonymous said...

clarification;
during my steps I removed the .deb file manually in the var/cache/apt/archives

with dpkg -l | grep php I haved this:
libapache2-mod-php5
php5-cli
php5-common
php5-mysql
php5-suhosin

and in archives I removed this:
libapache2-mod-php5_5.3.3-7+squeeze14_i386.deb
php5-cli_5.3.3-7+squeeze14_i386.deb
php5-common_5.3.3-7+squeeze14_i386.deb
php5-mysql_5.3.3-7+squeeze14_i386.deb
php5-suhosin_0.9.32.1-1_i386.deb


the code
rm -f /var/cache/apt/archives/php5*
remove only file that initiate whith php5... words;

remain
libapache2-mod-php5