さくらのVPS(CentOS 6.5)にRuby 2.1.1を入れました。
こちらのサイトを参考にさせていただきました。
普通にyumでインストールしようとしたのですが、
[shell toolbar=”true”]
# yum install ruby
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ruby x86_64 1.8.7.352-13.el6 updates 534 k
[/shell]
なー、古い!
インストール方法をいろいろと調べたところ、Ruby Version Manager(RVM)というものを使うべきだそうな。本家でも紹介されていました。
事前準備。
[shell]
# yum install gcc-c++ patch readline readline-devel zlib zlib-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison gdbm-devel tcl-devel tk-devel libxslt-devel libxml2-devel
# yum install –enablerepo=epel libyaml-devel
[/shell]
RVMのインストール。私しか使わないサーバなので、ユーザ毎に環境を作る必要性はなく、rootでインストールすることにしました。/usr/local配下にインストールされます。
[shell]
# curl -L https://get.rvm.io | bash -s stable
…
* First you need to add all users that will be using rvm to ‘rvm’ group,
and logout – login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.
* To start using RVM you need to run `source /etc/profile.d/rvm.sh`
in all your open shell windows, in rare cases you need to reopen all shell windows.
[/shell]
上記のメッセージが出ますが、rootで使うだけだったら、いったんログアウトしてログインすればオッケーみたい。
[shell]
# rvm -v
rvm 1.25.22 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
# rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1[.1]
[ruby-]2.1-head
ruby-head
[/shell]
インストール。コンパイルするので時間がかかります。
[shell]
# rvm install 2.1.1
# rvm docs generate-ri
[/shell]
無事にインストールできました。
[shell]
# ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
# irb
2.1.1 :001 > puts "Hello! World!"
Hello! World!
=> nil
[/shell]
一般ユーザでもRubyを使う場合は、source /etc/profile.d/rvm.shを実行します。
[shell]
$ source /etc/profile.d/rvm.sh
$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
$ irb
2.1.1 :001 > puts "Hello! World!"
Hello! World!
=> nil
[/shell]
終わり。
