Ruby on CentOS

In these days I’m trying to install Ruby on Rails on our CentOS production server. What I really don’t like very much about CentOS are its pretty outdated packages installable via yum. This time proved to be the same… it’s seems that the Ruby available on CentOS via yum is a version released during 2006.
In the first place I tried to compile Ruby from sources, but this proved a little too much messy for me. In the end I stumbled upon Ruby Enterprise Edition and I gave it a try.
What I liked most about it was that it worked perfectly just out of the box and that all Ruby files go inside a single directory, so it’s pretty easy to move from a version to another even if not using yum.
This is a brief tutorial about how to install Ruby Enterprise Edition on CentOS.

Get rid of any Ruby previously installed

First of all let’s remove any Ruby installation already present on our CentOS.
We can ask Yum to give us a list of Ruby related packages currently installed.

  1. yum list | grep installed | grep ruby

My server answered that way, but obviously yours can show other answers.

  1. ruby.i386 1.8.5-5.el5_3.7 installed
  2. ruby-devel.i386 1.8.5-5.el5_3.7 installed
  3. ruby-libs.i386 1.8.5-5.el5_3.7 installed
  4. ruby-mode.i386 1.8.5-5.el5_3.7 installed

Time to gently ask to Yum to remove all those Ruby packages.

  1. yum erase ruby
  2. yum erase ruby-devel
  3. yum erase ruby-libs
  4. yum erase ruby-mode

We can now start with the Enterprise Ruby installation.

Download and install Enterprise Ruby

There is really nothing deeply interesting here. Just download the sources, unpack them, compile them and set some useful links.

  1. mkdir -p ~/Temp/Sources
  2. cd ~/Temp/Sources
  3. wget
  4. tar xzvf ruby-enterprise-1.8.7-2010.01.tar.gz
  5. ./ruby-enterprise-1.8.7-2010.01/installer

At the end we should have a working Ruby installation.
Let’s create some useful link.

  1. ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/rake /usr/bin/rake
  2. ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/gem /usr/bin/gem
  3. ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/rails /usr/bin/rails
  4. ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby /usr/bin/ruby
  5. ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/irb /usr/bin/irb

Worth reading

Cristian Livadaru’s blog post about the topic.
Install the available Ruby via Yum
Enterprise Ruby download page