Debian Lenny - Ruby on Rails

In the Debian Lenny setup articles (page 1 and page 2) we secured, updated and personalized the install and we should be ready to add some working software.

We also installed the build-essential package. Now we can go ahead and install Ruby on Rails.


Process

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.

Ruby

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

Version

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.

RubyGems

As mentioned before, we're going to install RubyGems from source.

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:

wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz

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

Version

Once done, we can check the gem version with a:

gem -v
...
1.3.1

Good.

Update

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

Rails

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)

Done.

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

That's it

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.

Ben B

Article Comments:

conficker commented Thu Apr 09 16:37:34 UTC 2009:

see Chris, its that easy. I wonder though, is Ruby 2 much faster than Ruby 1.x?

Gaius Parx commented Sat Apr 18 19:57:06 UTC 2009:

sudo aptitude install exim4 subversion

It is missing the git portion

Ben B commented Wed Apr 29 00:42:41 UTC 2009:

@Gaius Parx: so it was, thanks for letting me know. I have added that back in.

Mr.Tree commented Wed May 20 17:45:36 UTC 2009:

At this time, when I update gem (with system's flag) it gone to the 1.3.3 version... does it gonna work?

Jordon Bedwell commented Tue Jun 23 18:32:17 UTC 2009:

You should mention in your tutorial that users need to install build-essential too because Debian and Ubuntu don't come with compiling capabilities out of the box like CentOS, and you will certainly need G++ to compile native Gems...

Ben B commented Wed Jun 24 23:15:56 UTC 2009:

@Mr.tree - Being that it is only a minor update, should work just fine. I've updated my rubygems to 1.3.3 as well and have had no issues.

@Jordon - Thanks for the suggestion. That is already covered in the second article in the debian series though: http://articles.slicehost.com/2009/3/31/debian-lenny-setup-page-2

Monte commented Thu Oct 29 12:01:34 UTC 2009:

Thanks for the help. Very useful information. I used this to install gem from sources. It worked perfectly. I followed the instructions, got gem 1.3.5, and worked without a hitch!

Sid Viswanathan commented Thu Dec 24 01:58:50 UTC 2009:

Setup worked without a single issue, great documentation, thanks!

Fábio commented Thu Jan 07 15:46:03 UTC 2010:

Congratulations on your step by step, it was useful for me

Dom commented Thu May 13 12:45:16 UTC 2010:

Thanks man!

darvein commented Fri Nov 12 21:21:03 UTC 2010:

hey! good tutorial! very usefull. thanks!!

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)