Skip to main content

Installing Rails on Ubuntu Dapper / Edgy

·412 words·2 mins· ·
General Everything RubyOnRails Features
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman

Update 2010-03-25: Bumped to RubyGems version 1.3.6.

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/69365/rubygems-1.3.6.tgz
tar zxf rubygems-1.3.6.tgz
cd rubygems-1.3.6
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.

Related

Migrate SQLite3 to MySQL easily
·275 words·2 mins
General Everything RubyOnRails Databases Features
Tagging in ajax_scaffold
·468 words·3 mins
General Everything Web Development RubyOnRails Features
Generate a SQlite-based Rails app
·187 words·1 min
General Everything RubyOnRails Databases SQlite Features