Downgrade php3 – php2, gỡ lỗi
PHP3 có hiện đại thật nhưng cũng hại điện không kém. Vì thế một số ứng dụng chỉ nên chạy với php2 (ví dụ như ứng dụng viết trên Zend Framework chẳng hạn).
Vì vậy bạn cần phải downgrade từ phiên bản 3 xuống phiên bản 2 khi đã lỡ cài đặt nó. Với windows thì việc này không vấn đề gì. Mình thường đặt sẵn mấy phiên bản PHP cạnh nhau, muốn đổi chỉ cần config lại apache là xong.
Tuy nhiên nó lại khá phiền toái với nhứng OS tự động cài đặt. Như Ubuntu mà mình đang sử dụng đây.
Vì thế sau khi search google, tìm được 2 đoạn shell script xài được. Note vào đây cho dễ nhớ này:
http://mrkandy.wordpress.com/2010/04/16/install-php-5-2-x-in-ubuntu-10-04-lucid/
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/lucid/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" " "`
#done
http://ubuntuforums.org/showthread.php?t=1459163
#!/bin/bash
# by Ruben Barkow (rubo77) http://www.entikey.z11.de/# Originally Posted by Bachstelze http://ubuntuforums.org/showthread.php?p=9080474#post9080474
# OK, here’s how to do the Apt magic to get PHP packages from the karmic repositories:echo “Am I root? “
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
echo “ NO!Error: You must be root to run this script.
Enter
sudo su
“
exit 1
fi
echo “ OK”;#install aptitude before, if you don`t have it:
apt-get install aptitude
# or if you prefer apt-get use:
# alias aptitude=’apt-get’# finish all apt-problems:
aptitude update
aptitude -f install
#apt-get -f install# remove all your existing PHP packages. You can list them with dpkg -l| grep php
PHPLIST=$(for i in $(dpkg -l | grep php|awk ‘{ print $2 }’ ); do echo $i; done)
echo these pachets will be removed: $PHPLIST
# you need not to purge, if you have upgraded from karmic:
aptitude remove $PHPLIST
# on a fresh install, you need purge:
# aptitude remove –purge $PHPLIST#Create a file each in /etc/apt/preferences.d like this (call it for example /etc/apt/preferences.d/php5_2);
#
#Package: php5
#Pin: release a=karmic
#Pin-Priority: 991
#
#The big problem is that wildcards don’t work, so you will need one such stanza for each PHP package you want to pull from karmic:echo ”>/etc/apt/preferences.d/php5_2
for i in $PHPLIST ; do echo “Package: $i
Pin: release a=karmic
Pin-Priority: 991
“>>/etc/apt/preferences.d/php5_2; done# duplicate your existing sources.list replacing lucid with karmic and save it in sources.list.d:
#sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list# better exactly only the needed sources, cause otherwise you can get a cachsize problem:
echo “# needed sources vor php5.2:
deb http://de.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic main restricteddeb http://de.archive.ubuntu.com/ubuntu/ karmic-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic-updates main restricteddeb http://de.archive.ubuntu.com/ubuntu/ karmic universe
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic universe
deb http://de.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic-updates universedeb http://de.archive.ubuntu.com/ubuntu/ karmic multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic multiverse
deb http://de.archive.ubuntu.com/ubuntu/ karmic-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic-updates multiversedeb http://security.ubuntu.com/ubuntu karmic-security main restricted
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted
deb http://security.ubuntu.com/ubuntu karmic-security universe
deb-src http://security.ubuntu.com/ubuntu karmic-security universe
deb http://security.ubuntu.com/ubuntu karmic-security multiverse
deb-src http://security.ubuntu.com/ubuntu karmic-security multiverse
” >> /etc/apt/sources.list.d/karmic.listaptitude update
apache2ctl restart
echo install new from karmic:
aptitude -t karmic install $PHPLIST# at the end retry the modul libapache2-mod-php5 in case it didn’t work the first time:
aptitude -t karmic install libapache2-mod-php5apache2ctl restart
php_installed=`dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
02 |
03 |
# remove all php packge |
04 |
sudo aptitude purge $php_installed |
05 |
06 |
# use karmic for php pakage |
07 |
# pin-params: a (archive), c (components), v (version), o (origin) and l (label). |
08 |
echo -e "Package: php5\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee /etc/apt/preferences.d/php > /dev/null |
09 |
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 |
10 |
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 |
11 |
echo -e "Package: php-pear\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee -a /etc/apt/preferences.d/php > /dev/null |
12 |
13 |
# add karmic to source list |
14 |
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 |
15 |
16 |
# update package database (use apt-get if aptitude crash) |
17 |
sudo apt-get update |
18 |
19 |
# install php |
20 |
sudo apt-get install $php_installed |
21 |
# or sudo aptitude install -t karmic php5-cli php5-cgi //for fcgi |
22 |
# or sudo apt-get install -t karmic libapache2-mod-php5 //for apache module |
23 |
24 |
sudo aptitude hold `dpkg -l | grep php5| awk '{print $2}' |tr "\n" " "` |
25 |
#done |