Entries tagged with “aptitude”.


I installed Ubuntu 10.04 on a few servers a while back, and instantly noticed a lot of problems with a few of our sites (that’s usually what happens when you do a major upgrade without reading any release notes!). I fairly quickly found out that the cause was that in Ubuntu 10.04, PHP is now running version 5.3 (it was 5.2 in previous releases).

Unfortunately, PHP 5.3 deprecates a few common features (see here for more info) which causes a lot of sites to just stop working, or act strangely.

I found that the best way to move forward was to downgrade PHP back to 5.2 while we could work out what the problem was with our sites (as is always the case in a fast moving development cycle, this was months ago and we haven’t got around to it yet). I found a really useful step by step guide to do this, and within 10 minutes the server was running 5.2 using the Ubuntu Karmic sources.

The guide can be found at http://mrkandy.wordpress.com/2010/04/16/install-php-5-2-x-in-ubuntu-10-04-lucid/ and I have to give all credit to the writer of that article. None of this was my own work, I just stumbled across the post above and it fixed all my problems (I’m hoping that it’ll help out some of my readers as well).

Anyway, here are the steps. It basically does the following: Remove all PHP packages, pin all PHP packages to karmic, add karmic to sources, and then reinstall the PHP packages which were previously installed.

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

And that’s it. As I said previously, all credit should go to the author of this post.

I finally decided to take the plunge and upgrade a few of my Etch servers to Lenny, and the process was a lot less painful than I was expecting.

These are basically the steps from the official manual, but I cant guarantee that your system will upgrade as easily as mine – as always when  upgrading you should backup your data and be prepared for the worst.

Usually I prefer apt-get over aptitude, but the official documentation recommends aptitude to do the upgrade, so heres what you need to do (as root)

First, edit /etc/apt/sources.list and change all mentions of etch to lenny. If you use vim, you can simply do the following:

vim /etc/apt/sources.list
(then, in vim)
:%s/etch/lenny/g
:wq

Then update…

aptitude update

At this point, you might receive the following error (I did on every server I upgraded)

W: There is no public key available for the following key IDs:
4D270D06F42584E6

W: You may want to run apt-get update to correct these problems

To fix this, you need to install the following:

aptitude install debian-archive-keyring
aptitude update

Now you’re ready to do the upgrade. The safest way to do this is in 3 parts

aptitude install aptitude
(updating apt first is a safe way of doing things)
aptitude upgrade
(when this finishes)
aptitude dist-upgrade

When this has finished, your system is upgraded to Lenny! All you need to do now is reboot, and hopefully the system will come back up and be running Lenny.