CentOS – Install Ruby on Rails from source

The version of Ruby available to CentOS users from the yum repository is woefully out of date. In this tutorial we will be installing ruby from source.

Install Development Tools

Before we are able to build Ruby from the source we will need to make sure that we have the Development Tools installed.

  1. su root
  2. yum groupinstall ‘Development Tools’
  3. exit

Install Ruby

NOTE: At the time of this writing the latest version available is: ruby-1.8.7-p302

  1. Ensure you are NOT logged in as root for the building process.
  2. wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p302.tar.gz
  3. tar -xvzf ruby-1.8.7-p302.tar.gz
  4. cd ruby-1.8.7-p302
  5. ./configure –enable-shared –disable-pthread CFLAGS=”-Wall -fno-strict-aliasing”
  6. make
  7. su root
  8. make install

Following the above steps you will now have ruby 1.8.7 (patch level 302) installed on your VPS.

Install RubyGems

Next we will install Ruby Gems from source also.

NOTE: At the time of this writing the latest version available is: rubygems-1.3.1.tgz

  1. For this process we WILL be logged in as root for the installation process.
  2. wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
  3. tar -xzvf rubygems-1.3.1.tgz
  4. cd rubygems-1.3.1
  5. ruby setup.rb
  6. gem -v-This command will display the version of gem
  7. gem list-This command will list all current gem installed on the system (don’t worry it will be blank for now)
  8. gem update –system
  9. gem list

Following the above steps you will now have rubygems 1.3.1 installed on your VPS. You have the full ability to install gems as you see fit. If you want to make them globally available install them as root, if you want to make them only available to the rails installation you should install them as the user under the configuration for that server.

Install rails gem

  1. For this process we WILL be logged in as root for the installation process.
  2. gem install rails
  3. gem list

Install mysql gem

  1. For this process we WILL be logged in as root for the installation process.
  2. yum install mysql-devel.x86_64
  3. gem install mysql –with-mysql-config=/usr/bin/mysql_config
  4. gem list

Trackbacks

  1. [...] NOTE: The version of Ruby available to CentOS users from the yum repository is out of date. At the time of this writing it is ruby 1.8.5 (2006-08-25). The good news is that this version has been tested by CentOS and their upstream source to correctly play nice with all other aspects of the operating system. The bad news is that it is version 1.8.5 and has not been updated for a long time (we don’t see it getting updated soon either). If you want to maintain the update path established from the main repository then this is the way to go. If you would like to install a newer version than this this article is the one for you (CentOS – Install Ruby on Rails from source. [...]