hard working ecommerce websites. hard working people. learn more.

Contact us

PHP 5.2.10 .debs for Ubuntu 10.4 (Lucid)

Everyone loves the latest-greatest, especially geeks and especially when it comes to geek toys like operating systems. A co-worker, who will go unnamed, couldn't resist the urge to install Ubuntu 10.4 (Lucid) the moment it was released. Ah, the beautiful interface, the cool toys, the modernity, the.... ouch! Hey, what the $#@*, my web sites don't work?!?

Unfortunately the latest-greatest is called the bleeding edge for a reason, and sometimes all that new goodness comes with an unhappy surprise. Lucid ships with PHP 5.3, which is the latest-greatest in the PHP world, however Drupal 5.x and 6.x (and as of this writing the yet-to-be-released 7.x) are not compatible with PHP 5.3. What's a poor latest-greatest-loving web developer to do? Fortunately we have options!

If you've done some googling you've likely discovered recipies for installing the Karmic PHP 5.2 .deb files on Lucid. Though I haven't tried it, this is reported to work. Rather than taking that option, I chose to rebuild the Karmic sources for PHP 5.2 on Lucid. The main difference being that the resulting .deb packages have been compiled against the newer libraries in Lucid. To my way of thinking this is a cleaner and safer way to do it, and it's essentially the reverse of how a typical "backport" would be done (where newer software is backported to an older operating system by compiling it against the libraries that came with that OS).

The attached .deb files are for PHP 5.2.10, built from the Karmic (9.10) sources against the various libraries that ship with Lucid. To use them with Lucid you will need to remove all existing PHP 5.3 packages (dpkg -r <package names>) and then download and install these PHP 5.2 packages (dpkg -i <package names>). Some of these packages are optional, as a minimum you will need php5-common and libapache2-mod-php5. If you're using Drupal you'll likely also want php5-mysql, php5-gd, and php5-curl too.

After you have installed these packages you will need to pin them, which will stop Lucid from wanting to upgrade you to PHP 5.3. After that you'll be good to go.

libapache2-mod-php5_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
libapache2-mod-php5filter_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5_5.2.10.dfsg.1-2ubuntu6.4_all.deb
php5-cgi_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-cli_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-common_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-curl_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-dbg_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-dev_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-gd_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-gmp_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-ldap_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-mhash_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-mysql_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-odbc_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-pgsql_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-pspell_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-recode_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-snmp_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-sqlite_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-sybase_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-tidy_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-xmlrpc_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php5-xsl_5.2.10.dfsg.1-2ubuntu6.4_i386.deb
php-pear_5.2.10.dfsg.1-2ubuntu6.4_all.deb

Comments

"however Drupal 5.x and 6.x (and as of this writing the yet-to-be-released 7.x) are not compatible with PHP 5.3".

This is not exactly true ;)

Drupal 6 itself is (apart from a bug in search.module, a patch has just been RTBC'd) compatible with PHP 5.3 but not compatible with E_DEPRECATED enabled. However, many contrib modules are still not so yes, many sites are in the end not compatible with PHP 5.3.

Drupal 7 is PHP 5.3, E_DEPRECATED *and* E_STRICT compatible. But again, contrib modules are a different story. As a fact, a recent patch for Drupal 7 forcefully actived E_STRICT which caused errors with contrib modules and was therefore reverted.

I *really* need to document that stuff on d.o :)

Berdir, thanks for the background information and all your work on D7!

So, it sounds like if you're running a version of D6 after 6.16 and you have any problems with PHP 5.3 you should look at the contrib modules you are using and, if possible, provide patches for modules that aren't compatible with PHP 5.3 via the module's issue queue, or at least check that there is a PHP 5.3 issue filed for the module.

You could also run this script to downgrade all installed php packages:

#! /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

cool script - worked great, thanks.

Hello

i have used your script and it worked great. My questions is, what should i do to undone this when the time comes and upgrade to 5.3?

If you've used the script above it will generate a file named /etc/apt/preferences.d/php. To undo the script and upgrade to php 5.3 you will need to delete the file (sudo rm /etc/apt/preferences.d/php), run sudo apt-get update, and then sudo apt-get dist-upgrade which will get the latest packages for your distribution, including the PHP packages.

Thank you Stijn for you very useful script.

I suggest that you add the following line and the end to prevent upgrade of downgraded packages through aptitude :

aptitude hold $php_packages

Didn't work for me. I still have 5.3.3

Same here. I still get 5.3. Any easy way to downgrade found?

#9 works like a charm!

Simple and straigh!

Thanks for this quick and efficient solution! @:)

Thank you for this, provided a quick and easy solution for my problems. Much appreciated!

Ben,

YOU ARE THE GREATEST !!!

Thank you - I spent one day looking for the solution until found your site.

This said I have to confess I spend 3 minutes, every day before going to bed saying a short prayer like this:

"Please God, Allah, Buddha, or whoever has the authority, keep an eye on this crazy Ubuntu guys an burn their fingers each time they approach the keyboard to modify a thing which is well know for running fine! "

Thank you Ben for the clear explanation of what is going on. Thank you Stijn for the script: it worked like a charm. Thank you Florian for the useful addition.
Very much appreciated: a problem that bugged me for days was solved in minutes.