1. Update the System and Install Common Software

On Ubuntu, run sudo apt-get update

1
2
3
sudo apt-get install -y git-core curl zlib1g-dev build-essential \
libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 \
libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common

Install MySQL
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
Set a password when prompted

2. Install rbenv

rbenv is a Ruby version manager built by Basecamp (formerly 37signals). It makes it easy to set Ruby versions for development, testing, and production. A similar, older tool is RVM. I chose rbenv because it's simpler, powerful, and focused.

  1. Clone rbenv into .rbenv
    git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

  2. Add ~/.rbenv/bin to your $PATH
    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc

  3. Add rbenv init to your shell
    echo 'eval "$(rbenv init -)"' >> ~/.zshrc

  4. Restart your shell and check whether the installation worked
    type rbenv => # "rbenv is a function"

  5. Install ruby-build.

Note: .zshrc is the zsh config file. If you use bash, use ~/.bashrc instead.

3. Install Ruby

Now you can install a specific Ruby version and set it as the global version

1
2
rbenv install 2.1.2
rbenv global 2.1.2

Run ruby -v to check the Ruby version you set

4. Install Rails

Once Ruby is installed, gem is available, so you can install Rails
gem install rails -v 4.1.2
rails -v
Check the Rails version

And that's it: Ruby on Rails is installed.

Notes:
OS: Ubuntu 14.04 x64
Ruby: 2.1.2
Rails: 4.1.2