Tag Archives: PHP

Installing PHP 5.2 on Ubuntu Lucid Lynx (10.04 LTS)

If you followed my previous post on downgrading your PHP installation, this may be of interest to you, since the Karmic security repositories are no longer available. There may be workarounds, but I couldn’t install PHP 5.2 following my previous instructions.

Here’s a different way to do it, that proved successful. Note that the install procedures outlined below, is for a fresh install of Ubuntu Server without the LAMP package selected during installation. If you want to adapt a system with 5.2 already installed, I’m sure you can figure it out using this post for inspiration.. 😛

First, you need to install add-apt-repository (root is assumed on all commands unless otherwise stated):

apt-get install add-apt-repository

Add the following into /etc/apt/preferences.d/php to pin PHP at version 5.2:

</pre>
Package: libapache2-mod-php5
Pin: version 5.2.10*
Pin-Priority: 991

Package: libapache2-<wbr>mod-php5filter
Pin: version 5.2.10*
Pin-Priority: 991</wbr>

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, we’ll be using PHP 5.2 compiled for Lucid Lynx (courtesy of Ralph Janke). Add Ralphs repository:

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

Update apt:

apt-get update

Install PHP 5.2:

apt-get install php5

Install MySQL if needed:

apt-get install mysql-server mysql-client

There. You should have a LAMP server up and running with PHP 5.2, without having to worry about Karmics repositories being gone, or an accidental upgrade to 5.3.

Advertisements

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