Install (downgrade) php 5.2.x in Ubuntu 10.04 Lucid

Today, all computers in my PHP department has been changed to Ubuntu 10.04. That's awesome ^^

But my current project is running on out of date PHP & Zend Framework versions that was deprecated from PHP 5.3.0

Our Windows server running on PHP 5.2.x version, so we decided... downgraded to 5.2.x, too :))

If you install LAMPP on Ubuntu 10.04, you're getting PHP 5.3.2 & it is not the version you want. You have at least 2 options to install PHP 5.2.x: - Download & build from source code - Change source.list to get older version

Because I'm newbie of Linux (Ubuntu) so I choose the simpler way to do, change source.list to get older version as bellow:

# remove all php packge sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`

use karmiс for php pakage

pin-params: a (archive), c (components), v (version), o (origin) and l (label).

echo -e "Package: php5\nPin: release a=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 a=karmic\nPin-Priority: 991\n"}'|sudo tee -a /etc/apt/preferences.d/php > /dev/null apt-cache search -n libapache2-mod-php5 |awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'| sudo tee -a /etc/apt/preferences.d/php > /dev/null echo -e "Package: php-pear\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee -a /etc/apt/preferences.d/php > /dev/null

add karmic to source list

grep 'main restricted' /etc/apt/sources.list|grep -v "#"| sed s/lucid/karmic/g | sudo tee /etc/apt/sources.list.d/karmic.list > /dev/null

update package database (use apt-get if aptitude crash)

sudo apt-get update

install php

sudo aptitude install -t karmic php5-cli php5-cgi

or (and) sudo apt-get install -t karmic libapache2-mod-php5

sudo aptitude hold `dpkg -l | grep php5| awk '{print $2}' |tr "\n" " "`


Source: mrkandy

Work fine!!!