Reverting from PHP 5.3.2 to 5.2 on Ubuntu Lucid Lynx (10.04.3 LTS)

I was tasked with transferring a CRM system from 2004 from our previous service provider to one of our own servers. Instead of installing old versions of PHP I decided to give PHP5 a try. It worked, but not as well as I had hoped. There were a lot of dependencies on deprecated functions (ereg_replace anyone?).

So.. what were my options? Install PHP4 or try a downgrade to 5.2. Most of the changes made between 5.2 and 5.3 seemed to be causing my troubles. Here’s a quick guide to downgrading PHP from 5.3 to 5.2 (all commands imply you are root or su):

php_installed=`dpkg -l | grep php | awk '{print $2}' | tr "\n" " "`

Remove the old PHP package:

sudo aptitude purge $php_installed

Use the karmic source for PHP instead:

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
egrep '(main restricted|universe|multiverse)' /etc/apt/sources.list|grep -v "#" | sed s/`lsb_release -s -c`/karmic/g | sudo tee /etc/apt/sources.list.d/karmic.list > /dev/null

Update your apt database:

sudo apt-get update

Install PHP again:

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

You may use the following commands to install additional modules if needed:

For fcgi:

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

For apache module:

sudo apt-get install -t karmic libapache2-mod-php5
Advertisements

One thought on “Reverting from PHP 5.3.2 to 5.2 on Ubuntu Lucid Lynx (10.04.3 LTS)

  1. Pingback: Installing PHP 5.2 on Ubuntu Lucid Lynx (10.04 LTS) « onlyblue@work

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s