Installing Ruby From Source
Often we are contacted by newbies and students who want to learn ruby on rails and want to gain some expertise in it. A very frequent problem for getting started with is the installation of ruby on their machine.
Follow these instructions to build and install Ruby on Rails. You have to install Ruby and RubyGems before you continue this tutorial. This should work on most Linux platforms and on MAC OS X. I never tried it on Windows.
Setting up your environment
Make sure your paths are correct. I am assuming you have some knowledge of Shell commands especially sudo. Dont misuse “sudo” as Great powers comes with great responsibilities. Normally I like to customize source and installation directories instead of using default ones. I will download source code into my custom directory. Source code doesn’t take up much space, and it’s useful to refer back to later to remind yourself of previous installation details or techniques, installed versions, for a fast install at a later time, or in case you want to uninstall something.
So lets create Source Directory. You will download and compile all the sources in this directory.
sudo mkdir -p /www/source
sudo chown -R group:user /www
sudo chmod -R 775 /www/source
Download and Build Ruby
Type these commands to download Ruby 1.9 p378. You can download latest version of ruby from here. Then follow these commands to extract and build ruby source.
cd /www/source
curl -O ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.1-p378.tar.gz
tar zxvf ruby-1.9.1-p378.tar.gz
cd ruby-1.9.1-p378
./configure --prefix=/www
make
make install-all
To verify that you have installed ruby successfully use this command. Make sure /www/bin is in your environment PATH.
which ruby # should return /www/bin/ruby
irb # should open interactive ruby console
Download and Build RubyGems
After installing ruby you can install RubyGems. For this example I will install RubyGems 1.3.7. You can download the latest version from here.
cd /www/source
curl -O http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
tar xzvf rubygems-1.3.7.tgz
cd rubygems-1.3.1
# use sudo if you need to
./setup.rb
Thats it. We’re Done
Congratulations. You have successfully installed Ruby and RubyGems. You might also want to build and install Ruby on Rails
Following
In the next post we will be writing about installing rails.
September 14th, 2010 12:29 pm
Wow this is a great resource.. I’m enjoying it.. good article