How To: Install and Compile Ruby 1.9.3+ from Source with libyaml on CentOS
If you are looking to install Ruby 1.9.3+ on a Linux system this will guide you through compiling the software. There is always the option to use yum to install ruby packages but the versions in repositories will be older, not the latest stable. This guide is using a Centos 5.x base system without any packages installed and all commands run as root.
1. First the system will need the appropriate packages to compile and install the source code for ruby. To do this run the following command.
yum -y install make gcc openssl-devel zlib-devel gcc gcc-c++ make autoconf readline-devel curl-devel expat-devel gettext-devel ncurses-devel sqlite3-devel mysql-devel httpd-devel wget which
2. Now that a compiler package is installed move on to download, compile and install the libyaml library.
cd /usr/src wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz tar zxf yaml-0.1.4.tar.gz cd yaml-0.1.4 ./configure --prefix=/usr/local make && make install
3. The next step is to download, compile and install Ruby 1.9.3.
cd /usr/src wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz tar zxf ruby-1.9.3-p0.tar.gz cd ruby-1.9.3-p0 ./configure --prefix=/usr/local --disable-install-doc --with-opt-dir=/usr/local/lib make && make install
4. Upon completion of steps 1 through 3 ruby is accessible via command line. Test ruby by running the following command.
[root@new-host-2 ~]# ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570)
The guide will help get Ruby working on a CentOS system, later I will cover what you can do with Ruby.
Related posts:


There is a typo in your directions for installing YAML. They should be
cd /usr/src
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar zxf yaml-0.1.4.tar.gz
cd yaml-0.1.4 ###ADDED THIS LINE HERE
./configure –prefix=/usr/local
make && make install
Thanks I just updated that.
Jon