Harm de Laat – 8 December 2009
220 words in about 1 minute

For this article I’m going to install a single (virtual) server to run a standard Ruby on Rails application. I will be using Apache2 and passenger for the webserver stack and MySQL as a database server. Let’s start by installing Ruby and all tools:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ apt-get install build-essential
$ apt-get install ruby irb ri rdoc libopenssl-ruby ruby1.8-dev
$ ruby -v
$ cd /usr/local/src
$ wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz # replace with latest version of rubygems
$ tar xfvz rubygems-1.3.5.tgz
$ cd rubygems-1.3.5
$ ruby setup.rb
$ ln -s /usr/bin/gem1.8 /usr/bin/gem
$ gem -v
$ gem install gemcutter
$ gem tumble
$ apt-get install mysql-server # this will ask for a password during installation
$ apt-get install libmysqlclient15-dev
$ gem install mysql
$ gem install rails
$ apt-get install git-core
$ apt-get install apache2
$ gem install passenger
$ passenger-install-apache2-module

Copy the following lines from the output and paste them at the end of the file /etc/apache2/apache2.conf. They should look something like this:

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

Finally let’s restart apache2:

1
$ /etc/init.d/apache2 restart

Phew! That’s it… We now have all the software we need on the server that’s required to deploy your Ruby on Rails app on Debian Linux (Lenny)! In a future article I’ll cover the basics of deployment using Capistrano.