Tutorial

How To Install Ruby on Rails on CentOS 6

Published on May 25, 2012
How To Install Ruby on Rails on CentOS 6

Status: Deprecated

This article covers a version of CentOS that is no longer supported. If you are currently operating a server running CentOS 6, we highly recommend upgrading or migrating to a supported version of CentOS.

Reason: CentOS 6 reached end of life (EOL) on November 30th, 2020 and no longer receives security patches or updates. For this reason, this guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other CentOS releases. If available, we strongly recommend using a guide written for the version of CentOS you are using.

The following DigitalOcean tutorial may be of immediate interest, as it outlines how to install Ruby on Rails on a CentOS 7 server:


About Ruby on Rails

Ruby on Rails is an application stack that provides web developers with a framework to quickly create a variety of web applications.

There are three separate processes required to install Ruby on Rails: you need to install Ruby, then the Ruby Gems, then Rails.

Set Up

The steps in this tutorial require the user to have root privileges. You can see how to set that up in the Initial Server Setup Tutorial in steps 3 and 4.

Step One—Install Ruby

The easiest way to install Ruby on your virtual server is through the yum package installer.

sudo yum install ruby

After you say yes to the prompt, Ruby will install.

Then we need some additional Ruby dependancies.

Type the following into terminal:

sudo yum install gcc g++ make automake autoconf curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel
sudo yum install ruby-rdoc ruby-devel

While it processes, the prompt may ask your permission to install the various packages. Go ahead and say yes each time.

Step Two—Install Ruby Gems

Once you have Ruby installed, you can easily install the ruby gems.

Type this command into terminal:

sudo yum install rubygems

After you have agreed to the prompt, ruby gems should be installed on your VPS. However, if you have any issues with this process, you can use an alternate method to install the Ruby Gems.

How to Install RubyGems from Source

If, for some reason, the yum installer doesn’t work for you, you can follow these steps to install ruby gems from the source.

To start, we will create a new directory to store the ruby code.

sudo mkdir ~/src
sudo cd ~/src

Then we can go ahead and download the ruby gems into the new folder. (You can always access the latest available gems by visiting:

http://rubygems.org/pages/download)

wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz?tar -zxvf rubygems-1.3.6.tgz
cd rubygems-1.3.6

Finally you are ready to install the ruby gems.

sudo ruby setup.rb

After you answer yes to the prompt, the gems will finish installing.

You will now be ready to install Rails on your virtual server.

Step Three—Install Rails

We should quickly do two updates to makes sure that everything is up-to date and set up correctly:

Check the gems:

sudo gem update

Then check the system overall:

sudo gem update --system

Once everything has processed, it is time to install Rails.

To start, open terminal and type in:

sudo gem install rails

This process may take a while, be patient with it.

If you are feeling especially antsy, you can type in:

sudo gem install rails -V

Terminal will then show you all the details of the process, so you can see that it is working.

After you answer yes to the prompt that comes up, rails will finish installing.

You have successfully installed Ruby on Rails!

See More

Once you have set up Ruby on Rails installed on your VPS, you can proceed to Create a SSL Certificate for your site or Install an FTP server

By Etel Sverdlov

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us


About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

dont know how, every time I face issue regarding CentOs, i find solutions on digitialocean blog when i search on Google :) damm good SEO u guys have done

TYPO

wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz?tar -zxvf rubygems-1.3.6.tgz

should be

wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
tar -zxvf rubygems-1.3.6.tgz

hi everyone,

im trying to install rails and i got this error;

[root@localhost ~]# gem install rails -v 3.2.17
ERROR:  http://rubygems.org/ does not appear to be a repository
ERROR:  Could not find a valid gem 'rails' (= 3.2.17) in any repository

can anyone help me with this issue.

also

im trying to install ruby using **curl ** but im also getting this error:

[root@localhost ~]# curl -L get.rvm.io | bash -s stable
curl: (7) couldn't connect to host

Sorry, should have finished reading the thread, I ran yum install patch and the problem was solved

I don’t know if this thread is still being monitored. I am trying to install RoR on Centos6.6.

Ruby is installed and OK RubyGems are also OK Had to install RVM to bring Ruby to 1.9.3 (ok) When I try and install rails it fails stating the i18n requires ruby version >= 1.9.3 ruby -v tells me I am running 1.9.3p551

I ran into an issue with my installation of rails due to my droplet not having the patch app installed. Possibly due to the fact I chose a base install and no other applications pre-installed.

In order to get rails installed, the nokogiri gem needs to be installed. In order for the nokogiri gem to be installed, the patch program needs to be installed.

yum install patch gem install rails

This did the trick for me.

I know this is a very old post, but this is what I came across on a google search and hopefully this knowledge will help others in the future if they run into the same issue as me.

UUUEAH! Sorry, that looks awful. Seems I have the same problem with formating as Javier did

I also got the error message: ERROR: Error installing rails: activesupport requires Ruby version >= 1.9.3. While installing Rails on RHEL 6.4 (Santiago) Specifying the version from 3.2.x worked for me:

sudo gem install rails -v 3.2.17

It seems Rails versions > 3.2.x does not support the Ruby versions =< 1.8.x which is what is in the RHEL Repos ( Source: http://rubyonrails.org/download )

List of latest Rail 3.2.x version available (currently 3.2.17) http://rubygems.org/gems/rails/versions

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
September 13, 2013

@jgc: It’s currently not possible to edit posts. I’ll get that fixed for you :]

Sorry this looks awful. I thought <code>… </code> would format it correctly.
I see now that I should have used code blocks: <pre>…</pre> No way to edit posts?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel