How to install Ruby 1.8.7 on CentOS 5.5 Linux

ruby, php, java, python code

Have you tried doing yum install ruby in CentOS 5.5? If you have the default repositories configured, you will notice that it installs the ancient Ruby 1.8.5. Not ready to move up to Ruby 1.9, but would like to install Ruby 1.8.7 – well here is how to do it!

Install Ruby 1.8.7 on CentOS 5.5 (or other distributions)

yum install -y gcc zlib zlib-devel
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p330.tar.gz
tar xvf ruby-1.8.7-p330.tar.gz
cd ruby-1.8.7-p330
./configure --enable-pthread
make
make install

See also  Fetch error installing Java on Ubuntu 11.04. Solved!

11 thoughts on “How to install Ruby 1.8.7 on CentOS 5.5 Linux”

  1. Well unfortunately this didn’t work out for me…

    I got this during make install:

    ./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb ./instruby.rb –make=”make” –dest-dir=”” –extout=”.ext” –mflags=”” –make-flags=”” –data-mode=0644 –prog-mode=0755 –installed-list .installed.list –mantype=”doc”
    /bin/sh: ./miniruby: No such file or directory
    make: *** [do-install-nodoc] Error 127

  2. @Kat – Are you using CentOS 5.5? Can you try going through the steps one more time and let me know if you still see the error?

  3. Even after repeating the steps in centos 5.5 ,it does’t work.I meant I am getting same error like Kat is getting

  4. This worked in compiling it but it still does not work in the correct path :

    [root@hostname ruby-1.8.7-p330]# ruby -v
    ruby 1.8.5 (2006-08-25) [x86_64-linux]
    [root@hostname ruby-1.8.7-p330]# ./ruby -v
    ruby 1.8.7 (2010-12-23 patchlevel 330) [x86_64-linux]
    [root@hostname ruby-1.8.7-p330]# which ruby
    /usr/local/bin/ruby
    [root@hostname ruby-1.8.7-p330]# which ./ruby
    ./ruby
    [root@hostname ruby-1.8.7-p330]#

  5. @alainchiaasson Try running configure with the prefix tag set to the default path. /usr.
    If you’ve ever used pirut or downloaded the rpm from the CentOS repos, then your gems and everything else expect ruby to be in /usr/bin, the libraries in /urr/lib and so on in that fashion.

    The default location specified in the config file is to put everything in /usr/local which will sort of mostly work, but may cause you some grief if you don’t feel like putting in the whole path when running a ruby executable. The fix is as easy as running configure again with the expected prefix location, then make and make install again.

    ./configure –prefix=/usr –enable-shared –enable-pthread
    make && sudo make install

    Best of luck.

Leave a Comment