We also installed the development tools package. Now we can go ahead and install Ruby on Rails.
The process will involve a mix of installation methods - the main ruby packages and dependencies will be installed using the 'yum' package manager, but rubygems will be installed from source.
The reason for this is that rubygems is not readily available through the repositories in yum . To get the latest and most stable version of rubygems onto the Slice we need to install from source.
Let's go ahead and install ruby.
For now, we'll stick to the basics and get the main Ruby on Rails packages installed:
sudo yum install ruby ruby-devel ruby-irb ruby-rdoc ruby-ri
Once done, we can have a look at the Ruby version:
ruby -v ... ruby 1.8.5 (2006-08-25) [x86_64-linux]
Good, now we can move onto installing rubygems for our Rails installation.
As mentioned, we're going to install rubygems from source.
Let's go ahead and download the source code into our sources directory. If you haven't got a sources directory, you can simply create one:
mkdir ~/sources cd ~/sources
At the time of writing the latest rubygems version is v1.3.1.
As normal, please check for the latest release on the rubygems homepage.
Let's download v1.3.1:
Now unpack it and move into the newly created folder:
tar xzvf rubygems-1.3.1.tgz cd rubygems-1.3.1
Now we can go through the simple process of compiling it:
sudo ruby setup.rb
Once done, we can check the gem version with a:
gem -v ... 1.3.1
We need to do a quick update to rubygems:
sudo gem update
Although nothing will change as we have installed the latest version, a '--system' update will ensure everything is the latest and greatest:
sudo gem update --system
Continuing with the Rails installation, we can go ahead and install it:
sudo gem install rails
Once completed, you can check what gems were installed with a:
sudo gem list
Which gives the following (from a fresh Slice and no other gems installed):
*** LOCAL GEMS *** actionmailer (2.3.2) actionpack (2.3.2) activerecord (2.3.2) activeresource (2.3.2) activesupport (2.3.2) rails (2.3.2) rake (0.8.4)
Rails version 2.0+ uses sqlite3 as its default database - you can, of course, use other databases and indeed, there will be articles specifically aimed at other databases.
We need to first install the necessary sqlite development package before installing the gem. Note the base sqlite package should already be installed on a fresh slice.
sudo yum install sqlite-devel
Now we can install the gem as follows:
sudo gem install sqlite3-ruby
Let's do a simple test to see if the module is working:
irb #irb(main):001:0> require 'rubygems' => true #irb(main):002:0> require 'sqlite3' => true
If the result does not return 'true' the you may have missed a step.
Postfix and Subversion
Finally, we need to install postfix and subversion so we can 'check-out' plugins and send mail from our Rails applications:
sudo yum install postfix subversion -y
Answer the postfix questions as you see fit but the defaults usually suffice for our purposes as we are only using it to send emails and not for receiving mail.
Note subversion may have previously been installed as part of the Development Tools groupinstall process in our CentOS Setup - Page 2 article.
You now have a Ruby on Rails and postfix/subversion stack setup and ready to roll.
Now you are ready to install the web server of your choice whether that be Litespeed, Nginx or Apache.