KAndy — Live

Install (downgrade) php 5.2.x in Ubuntu 10.04 Lucid

Posted on: 16 апреля, 2010

php_installed=`dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`

# remove all php packge
sudo aptitude purge $php_installed

# use karmic for php pakage
# pin-params:  a (archive), c (components), v (version), o (origin) and l (label).
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

# add karmic to source list
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 package database (use apt-get if aptitude crash)
sudo apt-get update

# install php
sudo apt-get install $php_installed
# or sudo aptitude install -t karmic php5-cli php5-cgi //for fcgi
# or  sudo apt-get install -t karmic  libapache2-mod-php5 //for apache module

sudo aptitude hold `dpkg -l | grep php5| awk '{print $2}' |tr "\n" " "`
U: script was updated for fix package pin
U: add comments neildrthomson@gmail.com to script
U: use `lsb_release -s -c` to get curent release
Метки: , , ,

комментариев 38 к "Install (downgrade) php 5.2.x in Ubuntu 10.04 Lucid"

Незаменимая статейка! Особенно для тех, у кого Zend_Debugger не работает под php-5.3 к коим я отношусь %)

[…] to go through the third solution and removed all PHP5.3 packages from the system, and found this explaining a strategy to install Karmic packages in 10.4 to run PHP as CGI, I prefer PHP5.2 to run […]

Thanz a lot!!! magento doesnt work with php 5.3. Thank you!!!

[…] W końcu zdecydowałem się zaktualizować Ubuntu do nowszej wersji 10.04. Ku mojemu zaskoczeniu upgradowi uległ też PHP do wersji 5.3. Nie jest to przeze mnie koniecznie porządane w tym momęcie gdyż mam masę projektów, które nie zadziałają (jeszcze) z PHP w najnowszej wersji. Dlatego koniecznym stał sie downgrade do wersji 5.2. Na necie można znaleść wiele wskazówek jak tego dokonać. Ja osobiście skorzystałem z treściwego artykułu pt. Install (downgrade) php 5.2.x in Ubuntu 10.04 Lucid. […]

It works great on Ubuntu 10.04 LTS, thanks a lot

This was great — thank you — and I have two additions:

Before starting, save a list of all the currently installed PHP packages:

# php_installed=`dpkg -l | grep php| awk ‘{print $2}’ |tr «\n» » «`

This makes it easier to re-install everything you had when complete, e.g., with:

# sudo apt-get install $php_installed

Also, instead of just the ‘main restricted’ repository, you might want to grab universe and multiverse, too. This can be done by replacing the ‘grep’ in line 10 with:

# egrep ‘(main restricted|universe|multiverse)’ /etc/apt/sources.list

I needed ‘universe’ in particular so that I could re-install phpmyadmin.

Great script, thanks! One addition, though for those that want the Karmic apache2 php 5.2 module installed — it wasn’t installed for me when I ran this script. Run this afterwards:

sudo aptitude install -t karmic libapache2-mod-php5

Also, seems like the «-e » from echo is getting emitted into the top and bottom of /etc/apt/preferences.d/php file. I handed edited to correct.

tnks for the perfect tutorial. I’ve tried it, but when i try to install phpmyadmin, ubuntu ask my to upgrade php and it’s dipendences. What I’ll have to do to obtain a system with apache 2, php 5.2, mysql and phpmyadmin tool?
Tnks for time and sorry for english. Please answer in english or italian 🙂

@Marco —

I had the same problems — see my comments above (#9). phpMyAdmin is in the «universe» repository, so add that (and, for good measure, the multiverse repos) to your /etc/apt/sources.list.d/karmic.list

The easiest way is with this command:

egrep ‘(main restricted|universe|multiverse)’ /etc/apt/sources.list | grep -v «#» | sed s/lucid/karmic/g | sudo tee /etc/apt/sources.list.d/karmic.list > /dev/null

Then run `apt-get update` again and pgpMyAdmin should install.

(MrKAndy — perhaps you might want to integrate my notes from #9 into your script? This would have helped @Mike in #11, too.)

A great THANK YOU!!!!!!

Thanks for the great tutorial but how would I do if I would like to revert the downgrade (basically upgrade to 5.3 again) ?

Thanks for the help everyone, I added =Fens lines — had to alter some characters and edit a little, I got
(script moved to post.)

Thanks so much! Worked like a charm.

[…] to Nick Veenhof, mrkandy, and their many commenters, from whom this script is […]

hold on… MrKandy,

your script is okay now.
But somehow,,, it just installing the basic php5.2 right?

How could we make it install the php5.2 including the extension as well… such as imap, gd and so on?

sudo aptitude install php5-{module name}
ex. sudo aptitude install php5-gd

This is unbelievable script! It worked like a charming on Ubuntu 10.4 with previously PHP 5.3 installed.

Thanks a lot!

hold on mr.kandy… I just got from your script result is php5.2.10

so then, how could I got the php5.2.14 now?

[…] para hacer la instalación de php5.2 es muy sencillo, con seguir los pasos del enlace de este blog lo tenemos […]

great, this helped me to downgrade. i actually needed to downgrade to work with drupal 6 as drupal 6 as some problems with php 5.3

Yes, the -e need to be removed from echo commands else you get two invalid headers in the /etc/apt/sources.list.d/karmic.list file.

I also had issues with php-apc so excluded that too:
#1 php_installed=`dpkg -l | awk ‘ /php/ && !/php-apc/ {printf «%s «,$2}’`

phpmyadmin installed, but 404 from http://localhost/phpmyadmin

Include /etc/phpmyadmin/apache.conf
to end of
and all good.

Thanks for the instructions. PHP5.3.2 really is no good for Drupal6!

Muchas gracias por el script, funciona de maravilla en maverick! solo hay que modificar «sed s/lucid/karmic/g» para que funcione.


[…] Тут писали невеликого скріпта для lucid, проте я трохи поправив (та шо буду вам свистіти, find/replace зробив і всьо) для маверіка, щоб повернутись до пихопе 5.2. […]

in order to resintall the packages i needed to add the karmic main repository to the karmic.lis file

отличный скрипт!
спасибо большое! мои php автотесты снова работают 🙂

This worked very well for me.
There were one or two things peculiar to my system which were easy enough to deal with given the excellent basis you gave us.
Many thanks! Very much appreciated!

Ubuntu 10.04 Kern 2.6.32-28-server #55,
works like a charm…

Yessss…………I love it, thanks so much…

Хороший пост! Одобряю

[…] downgraded PHP from 5.3 to 5.2 by doing something similar to mrkandy’s script Everything works fine except pear. pear list shows the pear packages I installed before the […]

Hello mr. KAndy… i can only say that you saved my day! Thanks for this great script…

This worked great until a few days ago when the Ubuntu Karmic archives were removed on archive.ubuntu.com
Now what to do? I still need PHP 5.2.x
Does anyone have any ideas?

Добавить комментарий

Заполните поля или щелкните по значку, чтобы оставить свой комментарий:

Логотип WordPress.com

Для комментария используется ваша учётная запись WordPress.com. Выход /  Изменить )

Фотография Twitter

Для комментария используется ваша учётная запись Twitter. Выход /  Изменить )

Фотография Facebook

Для комментария используется ваша учётная запись Facebook. Выход /  Изменить )

Connecting to %s


Обновления Twitter

  • RT @lonistark: 🥳 @AdobeCommerce new API-first extensibility capabilities is now generally available. Drastically reduces integration effort… 1 week ago
  • RT @lonistark: 🚀 Exciting expansion of Adobe & IBM partnership: integrated solution for retailers/brands that optimizes supply chain & orde… 1 week ago
  • RT @magentogirl: Are you an @AdobeCommerce Rockstar and would like to attend #AdobeSummit for FREE? Submit your best extensions, tips & tr… 2 weeks ago
  • RT @MarkShust: Great news -- Magento started working through community-prioritized issues! This initiative will help provide a voice to Ma… 1 month ago
  • RT @MarkShust: Today, support for both Magento 2.4.3 and PHP 7.4 ends! Each online store running 2.4.0-2.4.3 will be responsible for its ow… 2 months ago
%d такие блоггеры, как: