Howto install Rails 3.0, Ruby 1.9.2, MySQL 5.1 on Ubuntu Lucid 10.04 LTS or Ubuntu Maverick 10.10 or Ubuntu Natty 11.04 or Ubuntu Oneiric 11.10


For this tutorial, I will show you how to install Ruby 1.9.2 and Rails 3.0 from source because Ubuntu repository only has the outdated Ruby 1.9.1 package. To compile Ruby from source, you need to install compilers and libraries headers.

NOTE: This tutorial can be applied for Ubuntu Maverick 10.10. The only difference is installing libreadline6-dev instead of libreadline5-dev. But I highly recommend you guys to stay with Lucid 10.04 LTS for production server.

$ sudo apt-get -y install libc6-dev libssl-dev libmysql++-dev libsqlite3-dev make build-essential libssl-dev libreadline5-dev zlib1g-dev

Install Ruby 1.9.2 from source

$ cd /tmp
$ mkdir src
$ cd src
$ wget
$ tar xjvf ruby-1.9.2-p290.tar.bz2
$ cd ruby-1.9.2-p290
$ ./configure --prefix=/usr/local
$ sudo make && sudo make install

You can check if Ruby has been installed successfully by

$ ruby -v

and it should output

ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]

Should you see the “Happy new Ruby” returned, then your installation is ready to go

ruby -ropenssl -rzlib -rreadline -e "puts 'Happy new Ruby'"

Ruby 1.9 bundles RubyGem so you don’t have to install it

Install SQLite3 and MySQL 5.1

$ sudo apt-get install mysql-server-5.1 sqlite3

Please make sure you set a password for MySQL server.

Install Rails and essential gems

$ sudo gem update --system
$ sudo gem install mysql2 rails rack rake mysql sqlite3
$ sudo gem install ruby-debug19 -- --with-ruby-include=./ruby-1.9.2-p290/

We can check if all gems are installed successfully

$ gem list

and it should list

abstract (1.0.0)
actionmailer (3.0.9)
actionpack (3.0.9)
activemodel (3.0.9)
activerecord (3.0.9)
activeresource (3.0.6)
activesupport (3.0.9)

Now you can generate your own Rails app.

$ rails new demo -d mysql
$ cd demo
$ rails server

You should be able to see a welcome screen under your web-browser (

That’s all for now. See you in next tutorial.

About Jones Lee

Nothing much about me..

14 responses to “Howto install Rails 3.0, Ruby 1.9.2, MySQL 5.1 on Ubuntu Lucid 10.04 LTS or Ubuntu Maverick 10.10 or Ubuntu Natty 11.04 or Ubuntu Oneiric 11.10

  1. James Hynde

    Affordable web hosting with unlimited space and bandwidth starting at just $4/month

  2. when installing the gems you really only need to do the following:

    sudo gem install mysql mysql2 rails

    rails contains rake and rack already.

  3. Ken Wagner

    sudo gem update –system fails for 1.4.2. Also the wget ftp download is for a “zip” not a “tar” but works fine after unzipping the zip.

    Anyone using NetBeans with this setup: ruby 1.9.2 and gem 1.3.7?

    Ken Wagner

  4. Agnostik One

    Another great “How to”… Again, worked like a charm! 🙂
    Thanks and cheers! 😉

  5. The only problem I found with this method is the updgrading, because the tarball of ruby hasn’t a uninstall goal, so you got to do the uninstalling by your own, and then recompile ruby to get next versions.

    There’s an alternative to this, RVM. The problem with RVM is that is not supported by some of the IDEs (e.g. Aptana Rad Rails).

    Personally, I think ruby must to give us a ruby-$version.deb.

    • I totally agree with you on this. I myself also a regular RVM user on development machine but I do not yet use RVM for production yet though I’ve heard people had successes using RVM on production to split gemset for legacy 1.8.7 and 1.9. That being said, I believe RVM would becomes a great addition to server stack. I just need more case studies to testify this.

  6. coredump

    Thanks for the instructions, i was not successful at my earlier attempts but this worked!

  7. Pingback: Howto install Rails 2.3, Ruby 1.9.1, MySQL 5.1 on Ubuntu Lucid 10.04 LTS or Ubuntu Maverick 10.10 « The invincible!

  8. foo

    Another A+ Howto from Jones. Do you happen to know why it doesn’t compile under Ubuntu Oneiric? I know it is beta OS so it might have some problems.

  9. roberto

    good work,
    but for me was necessary install nodejs
    [on ubuntu 10.04]
    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:chris-lea/node.js
    sudo apt-get update
    sudo apt-get install nodejs

    many thanks Jones Lee

  10. bcursor

    Great Tutorial.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: