Red Hat Linux (and its recompiled cousin, CentOS) has a fantastic reputation for stability and maturity. However, this often means that packages included with the OS are somewhat out-of-date by the time the distribution is released. For example, the latest version of CentOS is 5.5, and the version of Ruby that ships with it is version 1.8.5, which dates back to August 2006. Even the Ruby group recommends using nothing less than 1.8.7 for Rails development.
So how do you get the stability of Red Hat with the goodness of Ruby? Compile from source to get the latest, greatest version. Here’s how:
1) Install CentOS 5.5
To save yourself alot of headaches during the installation, check to see if you have the “Development Tools” group installed with this command:
# yum grouplist |grep -i Development
If you don’t have it, install the package group with this command:
#yum groupinstall "Development Tools"
Note that you may also have the older version of Ruby installed via RPM’s. You can check to see if you have it with this command:
# rpm -qa |grep ruby
If you discover an older version, uninstall it before proceeding (rpm -e <package_name>).
2) Create a /sources directory and change to that directory.
3) Download and build Ruby.
Download the latest Ruby source code (latest version is 1.9.2-p0 as of this writing).
Uncompress the tarball and build Ruby:
tar -zxvf ruby-1.9.2-p0.tar.gz cd ruby-1.9.2-p0 ./configure make make install
If you have all the proper dependencies, you should have no errors during the configure or make phases. This will install Ruby to the following directories:
/usr/local/include/ruby /usr/local/bin/ruby /usr/local/lib/ruby /usr/local/share/doc/ruby/html /usr/local/share/man1
Once the install is complete, verify the version of Ruby:
# ruby -v ruby 1.9.2p0 (2010-08-18 revision 29036)
The Ruby source package also installs RubyGems, the Ruby package manager. Verify the version of RubyGems:
# gem -v 1.3.7
4) Check for updated gems
Ensure you have the latest gem versions by running this command:
# gem update --system
5) Install the rake build language
# gem install rake
6) Install rails
# gem install rails
7) List the installed gems.
# gem list
That’s it! You now have a fully-installed Ruby on Rails stack. However, Ruby also needs a back-end database and a web server for its presentation layer. Future posts will detail how to install and integrate web server and database tiers with Rails.