Monday, October 6, 2008

How to compile and install Ruby on RHEL 4

This is one of those posts where I'm mostly writing this so I can remember how to do it in the future. But maybe it will help someone else, too. I'm not a Unix sysadmin, by any means, but here is what I did to get, compile, and install Ruby on a RHEL 4 system at work. I realized later that I could have found and installed an RPM, but after I started down this path, I wanted to finish it.

First of all, this may seem backwards, but I set these environment variables first. This is because I messed up the first time I tried to install Ruby, so these were left hanging around.

export RUBYLIB=/opt/ruby/lib:/usr/lib/site_ruby
export PATH=$PATH:/opt/ruby:/opt/ruby/bin

Next I downloaded the Ruby source code:

wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz

I unarchived it:

tar -zxvf ruby-1.8.6.tar.gz

I made a symbolic link which will match the paths in the RUBYLIB and PATH environment variables I set up previously. Also, it's just a lot easier to type /opt/ruby instead of /opt/ruby-1.8.6-p287:

ln -s ruby-1.8.6-p287 ruby

Now, we build and install:

cd ruby
./configure
make
make install

I next installed RubyGems. First we download the archive and unpack:

wget http://rubyforge.org/frs/download.php/43985/rubygems-1.3.0.tgz
tar -zxvf rubygems-1.3.0.tgz

Then we run the setup:

cd rubygems-1.3.0
ruby setup.rb

And that is it!

No comments: