Ruby 1.8.7インストール

昨日( CentOS 5.4新規インストール - tetu1984の日記)の続き

Ruby 1.8.7をソースからインストールする。

ダウンロード

適当なディレクトリ作って、そこに保存、展開。

$ mkdir install
$ cd install/
$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.bz2
$ tar jxf ruby-1.8.7-p249.tar.bz2 
$ cd ruby-1.8.7-p249
インストール

Makefile作成・・・

$ ./configure --prefix=/usr/local/ruby/1.8.7
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

Cコンパイラが無いと言われたので、gccをyumでインストール

$ sudo yum install gcc

再度試みる

$ ./configure --prefix=/usr/local/ruby/1.8.7
$ make
$ sudo make install

無事に入ったらしいので、とりあず動作確認

$ /usr/local/ruby/1.8.7/bin/ruby --version
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]

動く事が確認できたので、PATHの設定

$ cd ~/
$ vim .bash_profile 
RUBY=/usr/local/ruby/1.8.7
PATH=$RUBY/bin:$PATH:$HOME/bin

$ source .bash_profile

動作確認

$ ruby --version
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
Hello World
$ irb
irb(main):001:0> puts "Hello World"
Hello World
=> nil