Reverting or downgrade PHP 5.3 to 5.2 in Ubuntu Lucid Lynx 10.04

So, you upgraded to Ubuntu 10.04 but suddenly your old applications like Drupal do not work on PHP 5.3 anymore? What the hell?

Without asking why it doesn't work because we would only loose time we want to go back to the version of PHP 5.2 where it does work!

Let us list all existing PHP packages to know what version we are running:
dpkg -l | grep php

So, now we are going to duplicate the existing sources.list and replace the lucid with karmic repos and saving it in sources.list.d
sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list

Create a file to be a little bit ahead of our apt-get system.
sudo nano /etc/apt/preferences.d/php
And insert the following text
Package: php5
Pin: release a=karmic
Pin-Priority: 991

Let's update the system. (You might want to do it twice to be sure)
sudo apt-get update

Installing php5 Karmic Packages. Attention! Only replace packages that were installed when doing the first command (remember the grep we did in the first step?)
sudo apt-get install php5=5.2.10.dfsg.1-2ubuntu6 php5-dev=5.2.10.dfsg.1-2ubuntu6 php-pear=5.2.10.dfsg.1-2ubuntu6 php5-cgi=5.2.10.dfsg.1-2ubuntu6 php5-cli=5.2.10.dfsg.1-2ubuntu6 php5-common=5.2.10.dfsg.1-2ubuntu6 php5-curl=5.2.10.dfsg.1-2ubuntu6 php5-gd=5.2.10.dfsg.1-2ubuntu6 php5-mcrypt=5.2.10.dfsg.1-2ubuntu6 php5-mysql=5.2.10.dfsg.1-2ubuntu6 php5-pgsql=5.2.10.dfsg.1-2ubuntu6

There you go! A fully function 5.2.10 PHP installation without troubles. If somebody knows how to make persistent so an upgrade does not replace them anymore feel free to add a comment to this post.

Comments

to not upgrade php 5.2 to 5.3 do this:

echo "php5-common hold" | dpkg --set-selections
echo "php5-cgi hold" | dpkg --set-selections
.
.
.
etc...

Worked like a charm, thanks.

For others who need to do this: in order to satisfy dependencies, you may need to change Ubuntu's versioning numbers as the Karmic repository evolves (eg. use

php5-common=5.2.10.dfsg.1-2ubuntu6.4

instead of

php5-common=5.2.10.dfsg.1-2ubuntu6

To prevent the upgrade to 5.3, I needed to do:


echo "php5 hold" | sudo dpkg --set-selections
echo "php5-common hold" | sudo dpkg --set-selections
...

I ran into a little problem using your method. Now, all my php files are not being processed via apache, and when I access them in the browser, the browser wants me to download the actual files.

Then the problem is probably that your php5 is not linked to apache
There is a package libapache2-mod-php5. Try to install it the same way as you did with the previous packages

I get an error version 5.2.10.dfsg.1-2ubuntu6 for php5 was not found

Any ideas? I have none - this is well above my head!

Thanks

This worked. I only had the php5 package in the /etc/apt/preferences.d/file so I added all the packages I installed for PHP, and I get a working 5.2 installation. Thanks.

Great, the mrkandy link above worked for me, so only one day of drupal development lost!
thanks heaps for all the pointers
dave t

Thanks for the groundwork Nick!

Mr. Kandy: your script automated everything!!

This worked indeed, thanks!

One extra note, I didn't have to specify the versions in the last install-command:

sudo apt-get install libapache2-mod-php5 php5 php5-common php5-gd php5-mcrypt php5-mysql php5-sqlite

Nick - That was brilliant and simple. Loved how you used the built in system configuration files to make the adjustments. Nice work!

It worked well for me.
there is just a package i can not install: php5-mcrypt
when i run apt-get install php5-mcrypt=5.2.10.dfsg.1-2ubuntu6 i get this error
E: Version â5.2.10.dfsg.1-2ubuntu6â for âphp5-mcryptâ was not found
What's wrong?
Thanks!!

Same here, I get:
E: Version '5.2.10.dfsg.1-2ubuntu6' for 'php5-mcrypt' was not found

Anyone know how to fix this?

I have the same mcrypt issue, and also phpmyadmin is uninstalled. having held the php5, php-common etc as described above, trying to reinstall phpmyadmin I get an error that mcrypt is a prereq but "not going to be installed"

Fixed - used Aptitude to reinstall phpmyadmin and that sorted out mcrypt too

Anyone know how to get php5-imap working after this downgrade.
It's telling me package not found.

Try to just type apt-get install php5-imap and see if he finds anything. If you cannot do it with the command go and take a look in synaptic and look for imap. When you select the package and go to Package > Force Version you should see the possibility to install a specific version of it. Choose the 5.2.6 or higher one.

When I try that I get the message
The following packages have unmet dependencies:
php5-imap: Depends: phpapi-20090626+lfs
E: Broken packages

Hi, I had the same problem with the mcrypt package. when I went to the package detail page of ubuntu i found out ir-t has another number.

So I did

sudo apt-get install php5-mcrypt=5.2.6-0ubuntu2

This worked for me, I hope this helps you

That worked for me

I ran
apt-get install php5-imap=5.2.6-0ubuntu6.1

Thanks for the heads up.

anyway... how if i wanted another php 5.2.x ?
I suppose there's another way arround rather than compiling it from the source... right, anyone?

I needed to install lib apache like this:

apt-get install libapache2-mod-php5=5.2.10.dfsg.1-2ubuntu6

Invaluable... THANKS!!!!!!

same here.....

Hi,

the latest php5-mcrypt version on karmic koala is 5.2.6-0ubuntu2

Alternatively try this:

apt-get install php5-mcrypt/karmic

You can do this for all appropriate php5 packages assumed you have installed the karmic repositories as described above.

Good fight, good night!

thank you very much for this excellent short tutorial

Time saving post Nick. Love your show!

First time I've ever had to downgrade anything while using Ubuntu. Very first encounter with anything resembling the 'dependency hell' of the old days :)

Confirmed on working like a charm when changing lucid to maverick in

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

for Ubuntu 10.10

Great job :-)

Does anyone know how best to reverse this without messing your server install up? I had reverted to PHP 5.2 sometime back, but with Drupal 7 out, I can go current again (5.3+). I tried:

sudo aptitude unhold php5

I also tried recompiling entirely from source, but somehow I am stuck with PHP 5.2 even after that.

Would deleting/editing the referenced preferences.d file fix this?

Thanks for any help!

You can delete the preferences if it is about php only (otherwise, just remove the php lines)
What I would suggest then is to do apt-get remove php5.

It will tell you which packages are depending on that. When this is done you can go ahead and install with a normal apt-get install php5 command.

If all of this does not work you could go to your package manager and select the php5 package, right click and select version (or in the menu bar, depending on the ubuntu) and select the 5.3 version.

Cheers

That worked for me.

Hi,
I need to get PHP 5.2.4 running on my Linux. Currently I have PHP 5.3.3, this is what sudo-apt get install installed according to php -v. I also need to get a good IDE up and running. I currently have chosen Eclipse. I plan on taking the time to understand your script and implement it. Can you give me a brief conceptual overview of how to accomplish these things. Questions I have.

Does Eclipse Install install PHP as well?

Why can't I just install a linux binaray for PHP 5.2.4 - there must be a place out there for them?

Is there a repository for PHP binaries?

Do different Ubuntu Linux versions require different binaries? If so where is this information?

Dude, that was awesome!

My package list was a bit different than yours (of course, depends on what you use) but your instructions were SPOT ON! A successful downgrade in under 30 mins, including searching out the packages I needed. To save anyone the searches, here's the packages I had to install:

libapache2-mod-php5=5.2.10.dfsg.1-2ubuntu6.7
php5=5.2.10.dfsg.1-2ubuntu6.7
php5-common=5.2.10.dfsg.1-2ubuntu6.7
php5-curl=5.2.10.dfsg.1-2ubuntu6.7
php5-mcrypt=5.2.10.dfsg.1-2ubuntu6.7
php5-mysql=5.2.10.dfsg.1-2ubuntu6.7
php5-suhosin=0.9.28-1
phpmyadmin=4:3.2.2.1-1

May the code be with you!

Cheers,
Not Worthy

Worked like a charm! Thanks a lot!
I actually downgraded to 5.2.6 so had to replace karmic with jaunty and "5.2.10.dfsg.1-2ubuntu6" to "5.2.6.dfsg.1-3ubuntu4.6" but it's basically the same, so once again a huge thank you! :-)

Sometimes Google is just a jungle and you just can't find anything. Thanks, that did the trick after 30 minutes of searching.

This has been a life saver! Seriously. Thank you for the clear instructions. I can move on to my next problem now. :)

This fix no longer works. Karmic was EOLed back in April. The packages are no longer available.

Seems Karmic has reached its End-of-Life? Anyone know how to get this to work now? I have a client on Drupal 5 which I need to support for a while before we can convert to 7.
Thanks for any help

For anyone (like me) who had problems getting the downgrade.. instead of the standard repo url (something like http://archive.ubuntu.com/ubuntu/) use http://old-releases.ubuntu.com/ubuntu that solved the issue for me.

This is cool!

<a href=http://prospect-consulting.ru/2012/01/25/vstuplenie-v-sro.html>
<img>http://s017.radikal.ru/i420/1112/69/7cdb34b6870c.jpg</img>
<img>http://s009.radikal.ru/i310/1112/74/7f45bca36f6e.png</img></a>

Tegs: вступление в проектное сро лицензируемые виды деятельности <b>фирма с допуском сро</b>.

<u>должностная инструкция вступление в сро </u>
<i>квалификация вступление в сро </i>
<b>юридическая фирма вступление в сро </b>

<a href=http://prospect-consulting.ru/2012/01/25/vstuplenie-v-sro.html>взыскание долгов вступление в сро </a>

Pages

Add new comment