Table of Contents
<span class="warning"><p></p>
<div name="status-deprecated" data-unique="status-deprecated"></div><h2 id="status-deprecated"><strong>Status:</strong> Deprecated</h2>
This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:
- Upgrade to Ubuntu 14.04.
- Upgrade from Ubuntu 14.04 to Ubuntu 16.04
- Migrate the server data to a supported version
Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.
Ruby On Rails (in short, Rails) is one of the most popular web development framework, In fact currently it’s the hottest web development stack, especially for Saas (Software as a Service) apps.
Prerequisites
Before installing Rails, I assume that you have already setup the server (created users, setup ssh etc). You can find how to do this here: Ubuntu Server Setup.
Step One - Install rbenv and dependencies
Before, installing any package, it’s always recommended to update package repository cache.
sudo apt-get update
Now, install git, curl and nodejs (javascript runtime is required in newer version of Rails). nodejs package is pretty outdated in official package repository, so install it from the PPA.
sudo apt-add-repository -y ppa:chris-lea/node.js
If you get the response sudo: apt-add-repository: command not found, you need to take one more step and install python properties to help you manage the repositories:
sudo apt-get install python-software-properties
Subsequently, you can take the next steps:
sudo apt-get -y update
sudo apt-get -y install curl git-core nodejs
Installing rbenv using a Installer
rbenv is a simple tool for managing multiple ruby versions, it’s like RVM (so you could also use RVM) but it’s light-weight and more simpler. To install rbenv we are using a simple script (hosted on github, you can checkout the code if you have any doubt).
First run the script,
curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
Now, update bashrc according to the instruction, add these lines to the top of your bashrc file:
nano ~/.bashrc
export RBENV_ROOT="${HOME}/.rbenv"
if [ -d "${RBENV_ROOT}" ]; then
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"
fi
Next, reload the shell.
source ~/.bashrc
Then, you should install the dependencies (using the installer tool),
rbenv bootstrap-ubuntu-12-04
Step Two - Install Ruby & gems
Install Ruby (and make it the default, that’s what the global option does here) 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
Step Three - Install Rails
Now, you can install the rails gem in one simple command –
gem install rails