Oh Shyte! Drupal 6? Provision a new Ubuntu server! How?

If you suddenly need to provision a new web app server for Drupal 6, the main problem you have is that the furthest back you can go, in say Ubuntu releases on Digital Ocean or Linode, is Ubuntu 10.04 LTS (Lucid Lynx). Default Php there is 5.3, and even though almost all contrib modules and core for Drupal 6 play nice with Php 5.3 these days, what about those monstrous legacy Drupal 6 sites that need to be maintained for "just a little bit longer" and whose modules cannot be upgraded easily due to dependency hell, or which for some reason, just need Php 5.2? This is a short article that, based on the following references, shows the steps I took to get the job done:

References:

Steps taken:

Grab an Ubuntu 10.04 LTS distrib. Then, the obligatory:

$ sudo apt-get update
$ sudo apt-get upgrade

Some prelims:

$ sudo apt-get install build-essential git-core subversion cvs python-software-properties curl

Add and pin Php repo to 5.2

$ sudo add-apt-repository ppa:txwikinger/php5.2
$ sudo wget http://github.com/jrbeeman/drupal-patches/raw/master/ubuntu-10.04-apt-ph... -O /etc/apt/preferences.d/php
$ sudo apt-get update

Lamp server as you would normally

$ sudo apt-get install apache2 php5 php5-cli php5-gd php-pear php5-dev apache2-dev
$ sudo apt-get install mysql-server php5-mysql
$ sudo a2dismod cgi autoindex
$ sudo a2enmod deflate expires rewrite vhost_alias
$ sudo /etc/init.d/apache2 restart
$ sudo pecl install apc

What've we got?

$ php --version
PHP 5.2.10-2ubuntu6.5 with Suhosin-Patch 0.9.7 (cli) (built: May 21 2010 05:51:15)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Mail server

$ sudo apt-get install postfix

Phpmyadmin

$ sudo apt-get install phpmyadmin

#fail Attempt to install drush the modern way (here's where the "oh shyte" part comes in)

(NO GO for PHP 5.2, just read the install drush via pear section)

$ sudo apt-get install php-pear (already done above)

$ sudo pear channel-discover pear.drush.org
$ sudo pear install drush/drush
$ sudo drush version
$ drush version
Your command line PHP installation is too old. Drush requires at [error]
least PHP 5.3.3.
$ sudo pear uninstall drush/drush

Install old Php 5.2 compatible drush the old-fashioned way

cd /usr/local/src
wget http://ftp.drupal.org/files/projects/drush-6.x-3.3.tar.gz
wget http://ftp.drupal.org/files/projects/drush_make-6.x-2.0-beta8.tar.gz
tar xzf drush-6.x-3.3.tar.gz
tar xzf drush_make-6.x-2.0-beta8.tar.gz
mkdir /etc/drush
cp /usr/local/src/drush/examples/example.drushrc.php /etc/drush/drushrc.php
ln -s /usr/local/src/drush/drush /usr/local/bin/drush
$ sudo drush version (first time)
$ drush

Now we get this pesky warning (does it matter?), at least on cli:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/mcrypt.so' - /usr/lib/php5/20060613+lfs/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0

Following Randy Fay,

http://randyfay.com/content/php-52-ubuntu-1004-lucid-lynx-seems-work-1204-too

https://bugs.launchpad.net/ubuntu/+source/php5/+bug/281979/comments/3

$ cat /etc/php5/conf.d/mcrypt.ini
# configuration for php MCrypt module
extension=mcrypt.so
$ sudo rm /etc/php5/conf.d/mcrypt.ini
$ php --version
PHP 5.2.10-2ubuntu6.5 with Suhosin-Patch 0.9.7 (cli) (built: May 21 2010 05:51:15)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Create virtual host as you normally would, and database, download drupal 6 with drush and you're good to go!