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.
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
Great tutorial! Thanks
Nice..it works. Thanks john
A different approach if you are using a Debian based distro:
https://github.com/yerv000/how_to-ruby_from_source
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?
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.