We also installed the build-essential package. Now we can go ahead and install Ruby on Rails.
The process will involve a mix of installation methods - the main ruby packages and dependencies will be installed using the 'aptitude' package manager, but RubyGems will be installed from source, as the Debian repository has a fairly outdated version.
Let's go ahead and install Ruby. Note, the install command shown below includes the sqlite3 db package as Rails version 2.0+ uses sqlite3 as its default database. You can, of course, use other databases and there will be articles specifically aimed at using other databases.
However, for now, we'll stick to the basics and get the main Ruby on Rails packages installed:
sudo aptitude install ruby-dev ruby ri rdoc irb libreadline-ruby libruby libopenssl-ruby sqlite3 libsqlite3-ruby libsqlite-dev libsqlite3-dev
Once done, we can have a look at the Ruby version:
ruby -v ... ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]
Good, now we can move onto installing RubyGems for our Rails installation.
As mentioned before, we're going to install RubyGems from source.
Let's go ahead and download the source code into our sources directory. If you haven't got a sources directory, you can simply create one:
mkdir ~/sources cd ~/sources
At the time of writing the latest RubyGems version is v1.3.1. You may want to check the RubyGems Homepage for a more recent version.
Let's download v1.3.1:
Now unpack it and move into the newly created folder:
tar xzvf rubygems-1.3.1.tgz cd rubygems-1.3.1
Now we can go through the simple process of compiling it and creating a symlink:
sudo ruby setup.rb ...
The compile and install process will take a minute or two to run, and when it's finished you should see the following displayed at the bottom of the output text:
RubyGems installed the following executables: /usr/bin/gem1.8 If `gem` was installed by a previous RubyGems installation, you may need to remove it by hand.
Let's create symlink:
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
Once done, we can check the gem version with a:
gem -v ... 1.3.1
We need to do a quick update to rubygems:
sudo gem update
Although nothing will change as we have installed the latest version, a '--system' update will ensure everything is the latest and greatest:
sudo gem update --system
Continuing with the Rails installation, we can go ahead and install it:
sudo gem install rails
It may take a few minutes to run, and once completed, you can check what gems were installed with a:
sudo gem list
Which gives the following (from a fresh Slice and no other gems installed):
*** LOCAL GEMS *** actionmailer (2.3.2) actionpack (2.3.2) activerecord (2.3.2) activeresource (2.3.2) activesupport (2.3.2) rails (2.3.2) rake (0.8.4)
Exim4, Subversion and Git
Finally, we need to install exim4, subversion and git so we can 'check-out' plugins and send mail from our Rails applications.
You may have noticed that we are using exim4 instead of postfix here, as Debian Lenny does seem to prefer exim4 and many packages depend on it. It is just as simple to setup and seems to have a lower memory footprint, so I am happy to oblige:
sudo aptitude install exim4 subversion git-core
You now have a Ruby on Rails and exim4/subversion/git stack setup and ready to roll.
Now you are ready to install the server of your choice whether that be Litespeed, Nginx or Apache.