Installing Rails on Ubuntu Dapper / Edgy

Update 2009-02-19: Bumped to RubyGems version 1.3.1 and MySQL 5 libraries. This guide now works for all recent version of Ubuntu and Debian. Enjoy!

Installing Ruby on Rails on your Ubuntu box is not always as easy as it seems. Here’s a comprehensive overview of the steps you need to take. Mostly you’ll be using apt-get and gems, so it’s not all that hard after all.

This method was tested on both Dapper and Edgy systems. It may work on other Ubuntu releases as well. It’s also possible that it works on Debian.

Besides Rails, I’ll also be install mysql and sqlite3 support.

1. Install Ruby

Before putting anything on Rails, install Ruby.

$ sudo apt-get install irb1.8 libreadline-ruby1.8 libruby libruby1.8 rdoc1.8 ruby ruby1.8 ruby1.8-dev

You may now check what version of Ruby you have by running `ruby -v`. It’s just for your information.

2. Install Ruby Gems

Surf to http://rubyforge.org/frs/?group_id=126 and download the latest available gems pacakge in tgz format. (You may also use the zip if you feel comfortable.)

$ wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
$ tar zxf rubygems-1.3.1.tgz
$ cd rubygems-1.3.1
$ sudo ruby setup.rb
$ sudo ln -sf /usr/bin/gem1.8 /usr/bin/gem

3. Install Rails!

You may now install Rails now!

$ sudo gem install rails

That’s it! Well, almost. You probably want some other things as well.

4. Install development tools

Before you continue, stop a moment to install some development tools. These tools are probably needed to compile and install the gems we are going to install next.

$ sudo apt-get install build-essential

MySQL Support

You probably want MySQL Ruby support. The MySQL code in Rails sucks (no offence), but the Ruby code is much better. You should install it. Rails will notice that it’s available and use it.

First, install MySQL.

$ sudo apt-get install mysql-server mysql-client

Next, install development files for MySQL. We’ll need these in order to make Ruby understand.

$ sudo apt-get install libmysqlclient15-dev

Then, you may install the gem

$ sudo gem install mysql

You have to choose what version you want to install. Enter the number corresponding with the latest version that is tagged ‘ruby’. Installing win32 stuff on linux is generally not a good thing.

SQLite 3

For SQLite 3 you need to install some packages before installing the gem.

$ sudo apt-get install sqlite3 libsqlite3-dev
$ sudo gem install sqlite3-ruby

If things go wrong

If things go wrong, make sure you installed all recommended packages mentioned above. Also , check any log files that the error message refers to.

  • Twitter
  • Digg
  • del.icio.us
  • DZone
  • Reddit
  • email

13 Responses to “Installing Rails on Ubuntu Dapper / Edgy”

  1. klevo says:

    Works like charm. Very nice tutorial!

  2. Gabriel says:

    Can you post about how to get a rails app running on apache2 with fastcgi on Ubuntu?

    To install the development tools, I use

    sudo apt-get install build-essential

    to take care of it.

    Also I recommend to install mongrel, its said to be better than webrick

    sudo gem install mongrel –include-dependencies

  3. Ariejan says:

    @Gabriel: I don’t currently use apache2 with fastcgi. I do use Apache 2.2 with mongrel_cluster, however.

    I’ll make a nice write-up about that soon! (Grab the RSS feed or get an email subscription to stay up-to-date)

  4. [...] Install ROR on Ubuntu Installing Ruby + Rails on Dapper and Edgy. I was missing bits using just the obvious packages. [...]

  5. Siema says:

    Thanks alot for this tutorial. Everything works like a charm!

  6. [...] Screenshots- Wardriving Using A Ubuntu Notebook With Garmin Etrex, Kismet, And GPSDrive (Breezy)- Instaling Ruby on Rails- Basic and Advanced Networking- Network Traffic Analyzer- Enabling WPA access Point- Sharing [...]

  7. [...] Screenshots- Wardriving Using A Ubuntu Notebook With Garmin Etrex, Kismet, And GPSDrive (Breezy)- Instaling Ruby on Rails- Basic and Advanced Networking- Network Traffic Analyzer- Enabling WPA access Point- Sharing [...]

  8. [...] Screenshots – Wardriving Using A Ubuntu Notebook With Garmin Etrex, Kismet, And GPSDrive (Breezy) – Instaling Ruby on Rails – Basic and Advanced Networking – Network Traffic Analyzer – Enabling WPA access Point – Sharing [...]

  9. many people did comments here, but Who did the instalation really Of Ruby on Rails on Ubuntu System 8.10, here?
    I’m having some problems with that configuration…

    I was until the step number #:
    3. Install Rails!

    I, in first, execute it:

    root@XXXCNN0596:/rubygems-0.9.0# gem install rails –include-dependendies

    And I received:

    ERROR: While executing gem … (OptionParser::InvalidOption)
    invalid option: –include-dependendies

    On sequence, I performed:

    root@XXXCNN0596:/rubygems-0.9.0# sudo gem install rails –include-dependendies

    I received:

    ERROR: While executing gem … (OptionParser::InvalidOption)
    invalid option: –include-dependendies

    Somebody in here, have any idea about it?

  10. Ariejan says:

    This post is quite old (2006), I just updated it use RubyGems 1.3.1 and the MySQL 5 libraries available to you in Ubuntu 8.10 and Debian 5.0.

    The include-dependencies option is no longer required (it's implied) by default.

  11. Dennis Blok says:

    You used –include-dependendies instead of dependencies, just a typo.. but as Ariejan says, it's no longer required.

  12. Ariejan says:

    Just installed a Debian Lenny VPS with this, all works like a charm.

Leave a Reply