PHP 5.2 on Ubuntu 10.04 Lucid Lynx (Seems to work for 12.04 too)

Edit 2012-11-12: If you're interested in the newer problem of running PHP 5.3 on Ubuntu 12.10 Quantal, try this recipe.

Edit 2012-09-21: Isn't it about time you moved to PHP 5.3? Even though these instructions seem to work even for Ubuntu 12.04, it's really time for people to move on to PHP 5.3. If you're a Drupal user on Drupal 6, Drupal core and nearly all contrib are now just fine with 5.3.

Edit 2011-11-23: Since Ubuntu 9.10 (Karmic) is now out of support, the repositories to use for it have changed to I've changed the karmic.list files attached. Please be aware that although 10.04LTS is still supported for years still, 9.10 is out of the support window, meaning that security issues in these packages will not be fixed.

Update: Look here to solve same problem with Ubuntu 10.10.

Lots of us are starting to run Drupal on Ubuntu 10.04 Lucid Lynx, and of course, Lucid comes with PHP 5.3, for which Drupal 6 is not yet ready.

I've seen a couple of fine recipes, but here's mine, with the files you need attached.

Update: You'll probably want to look at Khalid's more extensive discussion of various ways to do this.

Essentially, all you have to do is tell the apt system where to find Karmic packages and then tell it that you want it to use Karmic's PHP packages.

So put the attached karmic.list in /etc/apt/sources.list.d and the attached "php" into /etc/apt/preferences.d.


sudo apt-get update
sudo apt-get remove php5 libapache2-mod-php5 php5-xsl php5-gd php-pear php5-mysql php5-curl php5-memcache
sudo apt-get install php5 libapache2-mod-php5 php5-xsl php5-gd php-pear php5-mysql php5-curl php5-memcache

If you had not already installed apache, php, and mysql, you can do that with the above files in place and get the right versions without removing anything:

sudo apt-get update
sudo apt-get install apache2 mysql-server php5 libapache2-mod-php5 php5-xsl php5-gd php-pear libapache2-mod-auth-mysql php5-mysql php5-curl php5-memcache

Note that your php.ini will have been replace, so you have to reset custom settings like memory_limit.


by Gábor Hojtsy on Tue, 2010-06-01 03:27

Drupal 6 itself is known to be ready for PHP 5.3 except one known issue which is detailed at The contributed modules you run with might not be ready yet and ideally people would submit issues to the module maintainers just as with any other errors. That would fix the issues once and for all instead of everybody downgrading their hosting/development environments to lower PHP versions for the sake of workarounds.

by Halil on Tue, 2010-06-01 22:28

Yeah, its a shame that people needs to downgrade the PHP version for a workaround.

The submitting issue suggestion for modules to support PHP 5.3 is only the one side of the coin. On the other side, there are issues submitted for the modules but never been fixed for a couple of different reasons, like;

a) Module maintainer(s) prefer to spend their time and energy to port the module to D7 rather than supporting PHP 5.3 for their 6.x version module.
b) Module maintainer(s) can spare just a limited time to support their module and only available to support critical issues and they dont consider PHP 5.3 support as critical.
c) Module maintainer(s) are scared to break PHP 4.x support, which the module is initially announced to support that version, while they are making the module PHP 5.3 compatible.

Im not complaining or something, just stating what I have witnessed and/or sensed after spending some time on the issue queues about the subject.

by rfay on Wed, 2010-06-02 07:04

It's not just Drupal which could (or perhaps shouldn't, per Gabor's comment) push us back to 5.2. There are other things, like tool support. I use Eclipse with the Zend Debugger .so, and it's not available for 5.3 (yet?)

by Kirk Hings on Wed, 2010-06-02 16:22

Thanks for the instructions, unfortunately your looks like it got mangled, should be

Perhaps drupal upload mangled it to add the _0.?

by rfay on Wed, 2010-06-02 16:27

Please change the filename to just "php" - although I think it would work no matter what you called it.

by mcrittenden on Wed, 2010-06-09 09:07

If, after doing this, you're getting errors like:

Unable to load dynamic library '/usr/lib/php5/20060613+lfs/' ...

Then this comment has the answer.

Basically, you just need to delete /etc/php5/conf.d/mcrypt.ini and /etc/php5/conf.d/gd.ini

by Visitor on Wed, 2010-06-16 15:25

I was having "php5-mcrypt" issues when trying to install phpmyadmin after downgrading. Ultimately, I found this:

From there you can manually download php5-mcrypt 5.2.10 and install it. After that, phpmyadmin installs properly.

by Visitor on Sat, 2010-09-25 12:02

I have also had to pin my PHP to 5.2 in order to maintain a local drupal development environment that doesn't crash because of reference/array mismatches in the use of some arguments. Once php5-mcrypt-5.2.10 is installed in the manner suggested by VISITOR, the latest version of phpmyadmin can readily be installed (using your standard package installer).

by Visitor on Wed, 2010-06-23 08:45


not sure if this will work for everybody as I'm a newbie in linux, but this helped me to install php5-mcrypt and after that phpmyadmin:

apt-get install libltdl7 libmcrypt4



by iMadalin on Wed, 2010-07-28 08:20

i use zend server to have php 5.2 in ubuntu 10.04 and i get a lot faster in any changes i need in php configuration with it's nice web panel.

by acy76 on Fri, 2010-09-17 15:11

I also had problems with the php5-mcrypt extension not being enabled (phpMyAdmin was complaining about it).

I simply appended the package to the 'php' file in /etc/apt/preferences.d like this:

Package: php5-mcrypt
Pin: release a=karmic
Pin-Priority: 991

Now, php5-mcrypt is also downgraded with the rest of the php packages and all seems to be well.

It was also useful to remove both php5-mcrypt and phpmyadmin using the --purge directive, e.g.:

sudo apt-get --purge remove phpmyadmin

After that, I updated the package information (apt-get update) and reinstalled phpmyadmin; php5-mcrypt gets installed automatically as a dependency.

I had previously tried the workarounds suggested in the comments above, so if this doesn't work for you, try those as well, maybe I modified something else that I am forgetting to write about here.

phpMyAdmin should now work correctly, although you may have to delete all cookies for a successful login.

by iMadalin on Fri, 2010-09-17 16:51

you need mcrypt for many other stuff, phpmyadmin is just the worst nightmare when it comes to export databases. import goes well, but big databases (for drupal in my case) it isn't the right tool.

after having lot's of problems with it i've switched to mysql workbench that is the official application from

by foxy on Thu, 2010-09-23 06:45

this command in my ubuntu 10.04 doesnot work.

by rfay on Thu, 2010-09-23 07:07

Perhaps you don't have sudo installed?

As root, then:
apt-get install sudo

Other than that, do this stuff as root:
apt-get install apache2 ...

I also added these lines to /etc/apt/preferences.d/php so that I don't get errors when installing PECL libraries:

Package: php5-dev
Pin: release a=karmic
Pin-Priority: 991

by Josh Hamilton on Sat, 2011-03-05 14:22

If you also want to install apc, uploadprogress, and phpmyadmin, you should append the following to Randy's php file.

Package: php5-mcrypt
Pin: release a=karmic
Pin-Priority: 991

Package: php5-dev
Pin: release a=karmic
Pin-Priority: 991

I just installed a fresh ubuntu1004-server_64 put the sources files and php preferences, and now I get:

# sudo apt-get install apache2 mysql-server php5 libapache2-mod-php5 php5-xsl php5-gd php-pear libapache2-mod-auth-mysql php5-mysql php5-curl php5-memcache
Reading package lists... Done
Building dependency tree      
Reading state information... Done
apache2 is already the newest version.
Package php5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package php5 has no installation candidate

by rfay on Thu, 2011-03-31 11:14

Is it possible you didn't apt-get update first?

by zbbax on Wed, 2011-11-23 01:54

Since a while and don't exist anymore
replace them with:

by rfay on Wed, 2011-11-23 08:56

I updated this and the files. Would appreciate your review.

by Neill on Thu, 2011-12-15 04:56


Thanks for this great article.
I've carefully followed your instructions, but when I do an apt-get update it throws the error:

Reading package lists... Error!
E: Dynamic MMap ran out of room. Please increase the size of APT::Cache-Limit. Current value: 16777216. (man 5 apt.conf)
E: Error occurred while processing language-pack-kde-fur-base (NewVersion1)
E: Problem with MergeList /var/lib/apt/lists/old-releases.ubuntu.com_ubuntu_dists_karmic_main_binary-amd64_Packages
W: Unable to munmap
E: The package lists or status file could not be parsed or opened.

I tried upping the cache value, but it fails no matter how large I set it. Any ideas?


by rfay on Thu, 2011-12-15 08:45

This is really an apt system problem, and doesn't have to do with the issues under discussion here. You'll need to figure out how to increase the size of APT::Caache-limit in apt.conf. I think I've done that before, but don't remember the story. I think you'll find some answers by googling; if not, post on or - Good luck!

Oh, and it's probably time for you to move to 5.3. There's little reason to stay on 5.2 now.

by April on Fri, 2012-08-03 10:46

Thank you for putting this tutorial together, it helped me out a lot. It worked for me on both Ubuntu 10.4 and 12.4.

by Bob Dingman on Fri, 2012-09-21 08:43

May I suggest you add the sudo apt-get update line to your second case ("If you have not already installed apache . . .") as below?

sudo apt-get update
sudo apt-get install apache2 mysql-server php5 libapache2-mod-php5 php5-xsl php5-gd php-pear libapache2-mod-auth-mysql php5-mysql php5-curl php5-memcache

You need to run apt-get update to put in effect the pinning.

by rfay on Fri, 2012-09-21 09:16

Thanks - I did it.

by jhuebner on Sat, 2012-11-10 08:02

I updated apache on an older system and the php module wouldn't load anymore. The systems karmic.list was outdated so the attached one saved my a**.

Have a nice day!

Drupal theme by Kiwi Themes.