CentOS 5.5 に rvm で ruby をインストールする

rvm のインストール

http://beginrescueend.com/rvm/install/


今回は、一般ユーザでインストールを行う。
上記サイトを参考に

user$ bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

を実行したら

Downloading RVM from wayneeseguin branch master

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
Could not download 'https://github.com/wayneeseguin/rvm/tarball/master'.
  Make sure your certificates are up to date as described above.
  To continue in insecure mode run 'echo insecure >> ~/.curlrc'.

というエラーになった。。



いったんインストールシェルスクリプトをダウンロードして一部を書き換える。

$ wget https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer

この中の

if ! curl -L https://github.com/${_repo}/rvm/tarball/${_branch} -o ${rvm_archives_path}/${_repo}-rvm-${_branch}.tgz

if ! curl -Lk https://github.com/${_repo}/rvm/tarball/${_branch} -o ${rvm_archives_path}/${_repo}-rvm-${_branch}.tgz

のように証明書の警告を無視する k オプションを追加した。

再度インストールシェルスクリプトを実行する。

$ bash ./rvm-installer


CentOS 5.5にバンドルされているSSL証明書が古いようなので更新する。

# cd /etc/pki/tls/certs/
# cp ca-bundle.crt ca-bundle.crt.bak
# curl http://curl.haxx.se/ca/cacert.pem -o ca-bundle.crt

参考:
curlでまたSSLのエラーが出たので対処
http://d.hatena.ne.jp/kanonji/20111208/1323323155
GitHubにおけるSSLの認証エラーを回避するため、EV SSLルート証明書を追加する
http://d.hatena.ne.jp/tetsuyai/20110924/1316877887


再度実行。

$ bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

今度はインストールできたようだ。
ホームディレクトリに .rvm ができている。
また .bash_profile には以下のように追記されている。

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

反映

$ source ~/.bash_profile

確認

$ rvm -v

rvm 1.10.0 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]

ruby のインストール

v1.9.3 をインストールする。

$ rvm install 1.9.3

デフォルトで v1.9.3 を使用するように設定する。

$ rvm use 1.9.3 --default

確認

$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

$ gem -v
1.8.10

で、gem で git をインストールしようとしたら zlib がないというエラーが出た。

$ gem install git
ERROR:  Loading command: install (LoadError)
    cannot load such file -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

解決方法はこの辺に書いてありますね。
https://rvm.beginrescueend.com/packages/zlib/

zlib の他に readline, openssl もインストールしておく。

$ rvm pkg install readline
$ rvm pkg install zlib
$ rvm pkg install openssl

~/.rvm/usr 配下にインストールされる。

念のため、いったんアンインストールしておく。

$ rvm remove 1.9.3

入れたライブラリのパスを指定して1.9.3を再インストールする。

$ rvm install 1.9.3 -C --with-readline-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr --with-openssl-dir=$rvm_path/usr