Wednesday, May 12

Downgrading php in lucid

Currently I work with CodeIgniter 1.7.1 and one of the biggest issues with this release is the usage of deprecated functions in PHP 5.3, so it's imperative to downgrade the PHP version.
There are several methods, the most straightforward one is described in trk's weblog

The idea is to duplicate the repositories from lucid with the ones from karmic
$ sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list

Now we need to create a preference file where we'll add every file we need from PHP and set them to be installed from the karmic repository

$ gksudo gedit /etc/apt/preferences.d/php
Package: php5
Pin: release a=karmic
Pin-Priority: 991

Package: php5-dev
Pin: release a=karmic
Pin-Priority: 991

Package: php5-curl
Pin: release a=karmic
Pin-Priority: 991

Package: php5-gd
Pin: release a=karmic
Pin-Priority: 991

Package: php5-xdebug
Pin: release a=karmic
Pin-Priority: 991

Package: php-pear
Pin: release a=karmic
Pin-Priority: 991

Package: php5-cli
Pin: release a=karmic
Pin-Priority: 991

Package: php5-common
Pin: release a=karmic
Pin-Priority: 991

Package: libapache2-mod-php5
Pin: release a=karmic
Pin-Priority: 991

Package: php5-mysql
Pin: release a=karmic
Pin-Priority: 991

Now all we need is to "reinstall" the packages

$ sudo apt-get update && sudo apt-get install php5 php5-dev php5-curl php5-gd php5-xdebug php5-cli php-pear php5-mysql

And that's it, we have php 5.2 in lucid