In this article you will learn how to install Ruby on Rails (ROR) under Linux / UNIX environments.
What is Ruby on Rails?
Ruby on Rails is a web application development stack that provides developers with a framework to quickly create a variety of web applications. Ruby on Rails is very hot in market, especially if you are looking for developing scalable, flexible and applications for SaaS (Software as a service) applications.
To begin our installation of Ruby on Rails on our Debian based operating system Ubuntu 12.04 LTS, Let’s make sure that hostname is correctly setup.
Note: These instructions work under Ubuntu 10.04 LTS, Ubuntu 13, Debian 6 and Debian 7 and Debian 8 (Jessie)
In our case, our hostname is “anydomain.com”
First, we update our operating system’s repositories and then upgraded the packages installed.
Please note we are running all commands from a sudo enabled user.
|sudo apt-get update
sudo apt-get upgrade
Once the update and upgrade process is done we will install RVM. It is known as “Ruby Version Manager.” This enables you to run multiple versions of ruby under one server. It’s a great program and gives you the flexibility to run multiple versions which may be required if we are using any specific framework version application.
We need to install “curl” on this machine, which will be required later.
|sudo apt-get install curl|
Now, install RVM (Ruby Version Manager) by using the below command:
|sudo curl -L https://get.rvm.io | bash -s stable|
Above download the bash script and install. After the installation is complete you need to close your shell sessions and start a new one.
To make everything work, RVM has some of its own dependencies that needs to be installed which we can see by using the command below:
The output of the above commands will be similar to something below:
# For ruby:
apt-get –no-install-recommends install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev
Now, you need to follow the instructions that were given by executing “rvm requirements” command. In our case, we got the above output so we will simply copy the suggested copy and install the packages required to make it work.
|sudo apt-get –no-install-recommends install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev|
If you get any error that “zlib package may be missing” don’t panic. RVM explain this here hxxps://rvm.io/packages/zlib/
Install Ruby Using RVM
Now that we have RVM up and running we will easily install Ruby using RVM.
|rvm install 1.9.3|
You can use the above command to install multiple (other) versions of Ruby, if you wish.
Make Ruby your default program
Since Ruby is now installed, you’ll need to make it your default programs.
|rvm use 1.9.3 –default|
Now, the next step is to install Ruby Gems. Ruby Gems installs all required components for working with Ruby on Rails (ROR)
|rvm rubygems current|
Now, since we have everything setup it’s time to install Rails.
Open a new terminal and execute the command below.
|gem install rails|
The above command will take some time for its process so you need to be patient here.
Success! Once you get a “Completed” message, you have successfully installed Ruby on Rails (ROR) on your server / machine.