Wednesday, February 15

New downgrade of php in ubuntu

Canonical has removed the repositories for karmic release so the old method to downgrade PHP stopped working, here is another way to downgrade PHP to 5.2.x

First add the PPA to your repository list

$ sudo add-apt-repository ppa:txwikinger/php5.2


if you are in Lucid then that's it, if not edit the recently added entry and change your distribution codename for lucid


$ sudo vi /etc/apt/sources.list.d/txwikinger-php5_2-oneiric.list


for example I have


deb http://ppa.launchpad.net/txwikinger/php5.2/ubuntu oneiric main
deb-src http://ppa.launchpad.net/txwikinger/php5.2/ubuntu oneiric main


and I edited to


deb http://ppa.launchpad.net/txwikinger/php5.2/ubuntu lucid main
deb-src http://ppa.launchpad.net/txwikinger/php5.2/ubuntu lucid main


Now you need to add the pinpoint for php packages


$ sudo vi /etc/apt/preferences.d/php


And put the content


Package: libapache2-mod-php5
Pin: version 5.2.10*
Pin-Priority: 991

Package: libapache2-mod-php5filter
Pin: version 5.2.10*
Pin-Priority: 991

Package: php-pear
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-cgi
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-cli
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-common
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-curl
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-dbg
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-dev
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-gd
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-gmp
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-ldap
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-mhash
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-mysql
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-odbc
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-pgsql
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-pspell
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-recode
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-snmp
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-sqlite
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-sybase
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-tidy
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-xmlrpc
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-xsl
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-mcrypt
Pin: version 5.2.6*
Pin-Priority: 991

Package: php5-imap
Pin: version 5.2.6*
Pin-Priority: 991


Now it's time to update the pachage list


$ sudo apt-get update


Everything should run without errors or warnings, now install PHP 5.2


sudo apt-get install php-pear php5-dev php5-gd php5-mysql php5-sqlite libapache2-mod-php5