Skip to content

How To: Install and Compile Ruby 1.9.3+ from Source with libyaml on CentOS

by Jon on November 16th, 2011

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
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
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.

From → Linux, Tech

  1. brittany parsons permalink

    There is a typo in your directions for installing YAML. They should be

    cd /usr/src
    tar zxf yaml-0.1.4.tar.gz
    cd yaml-0.1.4 ###ADDED THIS LINE HERE
    ./configure –prefix=/usr/local
    make && make install

  2. Rob permalink

    Great tutorial! Thanks

  3. Marcus permalink works. Thanks john

  4. A different approach if you are using a Debian based distro:

  5. Jim Jenkins permalink

    I am trying to install Ruby from source on RedHat 6.6. I get an error when following this article. I get a compile error:

    make[2]: *** [ossl_pkey_ec.o] Error 1

    Alternatively I followed this tutorial to try to install Ruby 2.0.0.
    If I compile Ruby 2.0.0. I get this error:

    /bin/sh: .installed.list: Permission denied
    make: *** [clear-installed-list] Error 1

    Any ideas on how I can resolve this?

  6. Hello Jon,

    I have to compile ruby-1.9.3-p194 with yaml and openssl for puppet master but when I am compiling it, it’s only loading yaml but for the openssl I am getting error when going to install puppet master with ruby command-

    cd /puppe-3.8.6
    ruby install.rb
    ftools not found. Using FileUtils instead..
    Could not load openssl; cannot install

    help to get it compiled ruby with yaml and openssl with normal user, not with root user.

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

%d bloggers like this: