Did you find this information useful? Please donate:

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.

16 comments:

Anonymous said...

thanks

matthias said...

worked fine, thanks!

Anonymous said...

I have this error:
Err http://security.ubuntu.com karmic-security/main Sources
404 Not Found [IP: 91.189.92.184 80]
....
and
Err http://security.ubuntu.com karmic-security/main i386 Packages
404 Not Found [IP: 91.189.92.184 80]
Err http://security.ubuntu.com karmic-security/universe i386 ....

and

Err http://archive.ubuntu.com karmic/main Sources
404 Not Found [IP: 91.189.91.31 80]
Err http://archive.ubuntu.com karmic/universe Sources
404 Not Found [IP: 91.189.91.31 80]
Err http://archive.ubuntu.com karmic/multiverse Sources
404 Not Found [IP: 91.189.91.31 80]
Err http://archive.ubuntu.com karmic/restricted Sources
404 Not Found [IP: 91.189.91.31 80]
Err http://archive.ubuntu.com karmic/main i386 Packages
404 Not Found [IP: 91.189.91.31 80]
Err http://archive.ubuntu.com karmic/universe i386 Packages
404 Not Found [IP: 91.189.91.31 80]
Err http://archive.ubuntu.com karmic/multiverse i386 Packages
404 Not Found [IP: 91.189.91.31 80]

and

Err http://archive.ubuntu.com karmic-updates/main Sources
404 Not Found [IP: 91.189.91.31 80]
Err http://archive.ubuntu.com karmic-updates/universe Sources
404 Not Found [IP: 91.189.91.31 80]
Err http://archive.ubuntu.com karmic-updates/multiverse Sources
404 Not Found [IP: 91.189.91.31 80] ...
and
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/karmic/main/source/Sources 404 Not Found [IP: 91.189.91.31 80]

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/karmic/universe/source/Sources 4 04 Not Found [IP: 91.189.91.31 80]

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/karmic/multiverse/source/Sources 404 Not Found [IP: 91.189.91.31 80]
...

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/karmic-security/universe/binary- i386/Packages 404 Not Found [IP: 91.189.92.184 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/karmic-security/multiverse/binar y-i386/Packages 404 Not Found [IP: 91.189.92.184 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/karmic-security/restricted/binar y-i386/Packages 404 Not Found [IP: 91.189.92.184 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.

Simon Cornelius P Umacob 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?

Simon Cornelius P Umacob 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). =)

Simon Cornelius P Umacob 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?

Simon Cornelius P Umacob 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...

I retested but
after sudo apt-get update

remain some eror:
Err http://ftp.ro.debian.org lenny/main i386 Packages
Err http://ftp.ro.debian.org lenny/contrib i386 Packages
Err http://ftp.ro.debian.org lenny/non-free i386 Packages
404 Not Found [IP: 195.228.252.133 80]

Ign http://old-releases.ubuntu.com/ubuntu/ karmic-updates/main Translation-en
and other Ign msg

..
W: Failed to fetch http://ftp.ro.debian.org/debian/dists/lenny/main/binary-i386/Packages.gz
W: Failed to fetch http://ftp.ro.debian.org/debian/dists/lenny/contrib/binary-i386/Packages.gz
W: Failed to fetch http://ftp.ro.debian.org/debian/dists/lenny/non-free/binary-i386/Packages.gz
404 Not Found [IP: 195.228.252.133 80]

E: Some index files failed to download, they have been ignored, or old ones used instead.


But at the end after the installation go

php -v
PHP 5.2.10-2ubuntu6.10 with Suhosin-Patch 0.9.7 (cli) (built: May 2 2011 23:13:14)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Suhosin v0.9.28, Copyright (c) 2007, by SektionEins GmbH

not know if php work good (must to test).

small notice I have installed not only php5-cli php5-cgi libapache2-mod-php5 how in this post but all that I initially read with dpkg -l | grep php and are this (in my case) libapache2-mod-php5 php5-cli php5-common php5-mysql php5-suhosin


so some error remain during installtion(but are important?) and also is possible to have last php 5.2.17 (but not important for me)




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