Php downgrade after upgrading distro to Ubuntu 10.4 Lucid Lynx

May 18th, 2010
by Chris Chandler (DevelopingChris)

Many php applications have compatibility issues with php 5.3.1. Unfortunately in that is the only version currently available in the aptitude repositories for the latest version of Ubuntu.

Once you have either freshly installed Ubuntu and php, or after you update just your distro and do an apt-get update, you will be on 5.3. There are lots of people with this problem. Many of them have solutions. Most involve running lots of terse commands. Then I ran across this shell script that once you have everything installed for php 5.3 will downgrade your stack to 5.2.10 for you. Since I’ve had trouble finding the original source after a few days, here’s the source in case you need it.

#! /bin/sh
php_packages=dpkg -l | grep php | awk '{print $2}'

sudo apt-get remove $php_packages

sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list

sudo mkdir -p /etc/apt/preferences.d/

for package in $php_packages; do echo "Package: $package Pin: release a=karmic Pin-Priority: 991 " | sudo tee -a /etc/apt/preferences.d/php done

sudo apt-get update

sudo apt-get install $php_packages

Copy this script into a file in your home directory, make it executable and then run it. It set everything up for me really well.

Posted in programming | Comments (4)

4 Responses to “Php downgrade after upgrading distro to Ubuntu 10.4 Lucid Lynx”

  1. John Says:

    Hello Does this work for Ubuntu 10.10?

  2. Chris Chandler (DevelopingChris) Says:

    it should continue to work, except instead of searching for lucid, search for maverick. So all instances of lucid in the script need replaced with maverick and then it will replace the php sources with karmic. Stay tuned for an update, I’m upgrading to 10.10 on my main dev machine this weekend.

  3. Ratheesh Says:

    The script worked like a charm.Thank you very much for the script.

  4. Aaron Says:

    Karmic allows to install 5.2.10. Any way to install PHP 5.2.5 or 5.2.6 My App do not work in version beyond 5.2.6

    Thanks is advance.

Leave a Reply