Install Ruby on Rails In CentOS And Ubuntu
Ruby on Rails is a free, open source web application framework that allows you to build web applications more easily and quickly. There are hundreds of thousands popular applications such as Basecamp, GitHub, Shopify, Airbnb, Twitch, SoundCloud, Hulu, Zendesk, Square, Highrise, and many are built using Ruby on Rails.
In this tutorial, we will see how to install Install Ruby on Rails on CentOS 7 and Ubuntu 16.04 LTS server. The installation steps given below should work on other DEB and RPM based distributions.
Install Ruby on Rails
Update and upgrade your Ubuntu system with command:
sudo apt-get update
sudo apt-get upgrade
On CentOS, run:
sudo yum update
Then install Ruby enVironment Manager(shortly RVM). It is a command line tool that can be used to easily install, manage, an work with multiple Ruby environments.
We need to download and add RVM public key.
To do so, install curl package first.
sudo yum install curl
sudo apt-get install curl
Now, run the following commands one by one to download and add RVM public key:
curl -#LO https://rvm.io/mpapis.asc
gpg --import mpapis.asc
Download RVM installer script using command:
curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.27.0.tar.gz Downloading https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc gpg: Signature made Tuesday 29 March 2016 07:19:47 PM IST using RSA key ID BF04FF17 gpg: Good signature from "Michal Papis (RVM signing) <email@example.com>" gpg: Note: This key has expired! Primary key fingerprint: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3 Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36 166B E206 C29F BF04 FF17 GPG verified '/home/sk/.rvm/archives/rvm-1.27.0.tgz' Installing RVM to /home/sk/.rvm/ Adding rvm PATH line to /home/sk/.profile /home/sk/.mkshrc /home/sk/.bashrc /home/sk/.zshrc. Adding rvm loading line to /home/sk/.profile /home/sk/.bash_profile /home/sk/.zlogin. Installation of RVM in /home/sk/.rvm/ is almost complete: * To start using RVM you need to run `source /home/sk/.rvm/scripts/rvm` in all your open shell windows, in rare cases you need to reopen all shell windows. # sk, # # Thank you for using RVM! # We sincerely hope that RVM helps to make your life easier and more enjoyable!!! # # ~Wayne, Michal & team. In case of problems: https://rvm.io/help and https://twitter.com/rvm_io
As you noticed in the above output, there is a line that says “to start using RVM you need to run `source /home/sk/.rvm/scripts/rvm`”:
So, let us run that command to set the RVM environment path:
On RPM based systems, this line might be different. Check on your output and run the command accordingly. In my CentOS 7 OS I got – To start using RVM you need to run `source /etc/profile.d/rvm.sh`.
So, I ran the following command:
After adding the RVM path, run the following command to install RVM dependencies.
Checking requirements for ubuntu. Installing requirements for ubuntu. Updating system .. . Installing required packages: g++, gcc, make, libc6-dev, libreadline6-dev, zlib1g-dev, libssl-dev, libyaml-dev, libsqlite3-dev, sqlite3, autoconf, libgmp-dev, libgdbm-dev, libncurses5-dev, automake, libtool, bison, pkg-config, libffi-dev............................... Requirements installation successful.
We have completed the prerequisites for Ruby on Rails.
Let us go ahead and install Ruby and Rails.
Now, let us find out the available Ruby versions using command:
rvm list known
# MRI Rubies [ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p330] [ruby-]1.9.3[-p551] [ruby-]2.0.0[-p648] [ruby-]2.1[.8] [ruby-]2.2[.4] [ruby-]2.3[.0] [ruby-]2.2-head ruby-head # for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2 # JRuby jruby-1.6[.8] jruby-1.7[.23] jruby[-184.108.40.206] jruby-head # Rubinius rbx-1[.4.3] rbx-2.3[.0] rbx-2.4[.1] rbx[-2.5.8] rbx-head # Opal opal # Minimalistic ruby implementation - ISO 30170:2012 mruby[-head] # Ruby Enterprise Edition ree-1.8.6 ree[-1.8.7][-2012.02] # GoRuby goruby # Topaz topaz # MagLev maglev[-head] maglev-1.0.0 # Mac OS X Snow Leopard Or Newer macruby-0.10 macruby-0.11 macruby[-0.12] macruby-nightly macruby-head # IronRuby ironruby[-1.1.3] ironruby-head
To install any Ruby version, for example 2.3.0, run the following command from Terminal:
rvm install 2.3.0
Searching for binary rubies, this might take some time. No binary rubies available for: ubuntu/16.04/x86_64/ruby-2.3.0. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for ubuntu. Requirements installation successful. Installing Ruby from source to: /home/sk/.rvm/rubies/ruby-2.3.0, this may take a while depending on your cpu(s)... ruby-2.3.0 - #downloading ruby-2.3.0, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 13.5M 100 13.5M 0 0 65676 0 0:03:35 0:03:35 --:--:-- 64044 ruby-2.3.0 - #extracting ruby-2.3.0 to /home/sk/.rvm/src/ruby-2.3.0.... ruby-2.3.0 - #configuring.......................................................... ruby-2.3.0 - #post-configuration.. ruby-2.3.0 - #compiling................................................................................ ruby-2.3.0 - #installing............. ruby-2.3.0 - #making binaries executable.. Installed rubygems 2.5.1 is newer than 2.4.8 provided with installed ruby, skipping installation, use --force to force installation. ruby-2.3.0 - #gemset created /home/sk/.rvm/gems/ruby-2.3.0@global ruby-2.3.0 - #importing gemset /home/sk/.rvm/gemsets/global.gems............................................... ruby-2.3.0 - #generating global wrappers........ ruby-2.3.0 - #gemset created /home/sk/.rvm/gems/ruby-2.3.0 ruby-2.3.0 - #importing gemsetfile /home/sk/.rvm/gemsets/default.gems evaluated to empty gem list ruby-2.3.0 - #generating default wrappers........ ruby-2.3.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake). Install of ruby-2.3.0 - #complete Ruby was built without documentation, to build it run: rvm docs generate-ri
Finally, set Ruby default version using command:
rvm use 2.3.0 --default
To find out the installed Ruby version, run:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
That’s it. Next, we need to install Rails.
To install Rails, run:
gem install rails
Or, run the following command to install a particular version of rails.
gem install rails -v 4.2.6
To view the installed version of Rails, run:
That’s it. Ruby and Rails has been installed in Ubuntu 16.04 LTS server.
For detailed guide about setting up Ruby and Rails development environment visit the link given at the end of the this tutorial.
If you find this tutorial useful, please share it on your social, professional networks and support OSTechNix.
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!