Installing Ruby on Rails via Passenger on Ubuntu 8.04

As part of my postings which focus on ‘Things I’ve Had to Do Recently So Am Writing Them Down So I Don’t Forget’ i’m writing up what I had to do to get Ruby on Rails up and running on my Ubuntu 8.04 development machine. As before, I’d expect this to run fine on the latest Ubuntu release (8.10 at time of writing).

Installing Apache

Apache installation is nice and easy under Ubuntu and I’m really only including the instructions for the sake of completeness.

sudo apt-get install apache2

Installing Ruby

Again installing Ruby itself is one of the simple things to get done.

sudo apt-get install ruby-full build-essential

Installing Rails

The best way to install Rails is via Ruby Gems, this allows Gems to be in control of updating Rails (and other Ruby related downloads) and prevents Apt from conflicting with your Gems package.

The latest version of Gems is 1.3.1 which can be installed with the following set of commands.

wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar xzvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system

With Gems now installed its safe to install Rails.

sudo gem install rails

Installing Passenger

Now that Ruby, Rails and Apache are installed the final step is the installation of Phusion Passenger (or mod_rails as it’s also sometimes referred to). Passenger can be installed through ruby gems which makes it easier to stay up to date with the latest release.

sudo gem install passenger
sudo passenger-install-apache2-module

Then add the following lines to your httpd.conf

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/bin/ruby1.8

You should now be able to set up a rails app and get it running by pointing an Apache VHost at the directory.

I’d also recommend setting Rails to development mode by adding

RailsEnv development

to your vhost’s config so you can see any errors generated by Rails in the case that something has gone wrong.