Install PHP 5.2 on Ubuntu Dapper

The repositories on Ubuntu Dapper don’t have php 5.2. To install php 5.2, I added the hardy repositories.

vi /etc/apt/sources.list

add the repositories
deb http://us.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ hardy main restricted

then run
sudo apt-get update
sudo apt-get install php5

This tried to install and upgrade a lot of packages including apache. I really needed php 5.2 and since the server is a development server, I accepted all the changes.

Sinatra: Suppress Newline in ERB

To suppress newline in ERB on Rails, you just add a dash on the closing tag -%>. In Sinatra, as of version 0.9.4, adding a dash doesn’t work. This has been fixed recently on the tilt gem version 0.3 which Sinatra uses for templates. You also need Sinatra newer than 0.9.4, which doesn’t exist yet so you need to get Sinatra from source.

You need to get tilt 0.3 from gemcutter.org.
sudo gem install --no-ri --no-rdoc tilt --source=http://gemcutter.org

To get the latest Sinatra
cd myapp
git clone git://github.com/sinatra/sinatra.git

and add it to the LOAD_PATH
$LOAD_PATH.unshift File.dirname(__FILE__) + '/sinatra/lib'

To set the dash as the ‘trim’ character, add
set :erb, :trim => '-'