How to Install Ruby On Rails on Ubuntu 12.04 LTS with Rbenv



Ruby on Rails is an open source web framework that runs on Ruby programming language. The integrated use of Ruby programming language and Rails development framework makes it popular among developers creating sites and web apps, especially for SaaS apps.

I assume that you have already done the Ubuntu server set up. Also the user should have root privileges. If not, refer to this tutorial for doing the initial Ubuntu 14.04 server set up and creation of new privileged user.


Installing Rbenv and Dependencies


Rbenv is a simple ruby version management tool with few features for specific requirements. It can be used as an alternative to RVM.

First, before installing anything update the package repository cache:

sudo apt-get update

Now, you can install git, curl and node.js packages.

sudo apt-add-repository -y ppa:chris-lea/node.js

Since the nodejs package is outdated in official package repository, we have installed it from the PPA.

In case if you get the below output,

sudo: apt-add-repository: command not found

You will have to install python properties to manage the repositories:

sudo apt-get install python-software-properties

Finish up by installing the rest of the packages:

sudo apt-get -y update
sudo apt-get -y install curl git-core nodejs


Installation of Rbenv Using Installer


Here, we will be using a simple script to install rbenv.

First of all, run the script:

curl | bash

Now, you need to add the following lines of code to the bachrc file:

nano ~/.bashrc 
export RBENV_ROOT="${HOME}/.rbenv"
if [ -d "${RBENV_ROOT}" ]; then
  export PATH="${RBENV_ROOT}/bin:${PATH}"
  eval "$(rbenv init -)"

Reload the shell:

source ~/.bashrc

Once you have completed these steps, you can proceed with installing dependencies using the installer tool:

rbenv bootstrap-ubuntu-12-04


Installing Ruby & Gems


Follow the steps for installing ruby and gems:

rbenv install 1.9.3-p392
rbenv rehash
rbenv global 1.9.3-p392

For Bundler and rake:

gem install rdoc
gem install bundler
gem install rake 
rbenv rehash


Installing Rails


Install the rails using the following command:

gem install rails


That’s it!


support2 has written 111 articles

Leave a Reply