さくらのVPS(CentOS 6.5)にRuby 2.1.1を入れました。
こちらのサイトを参考にさせていただきました。
普通にyumでインストールしようとしたのですが、
1 2 3 4 5 6 | # yum install ruby ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: ruby x86_64 1.8.7.352-13.el6 updates 534 k |
なー、古い!
インストール方法をいろいろと調べたところ、Ruby Version Manager(RVM)というものを使うべきだそうな。本家でも紹介されていました。
事前準備。
1 2 | # 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 |
RVMのインストール。私しか使わないサーバなので、ユーザ毎に環境を作る必要性はなく、rootでインストールすることにしました。/usr/local配下にインストールされます。
1 2 3 4 5 6 7 | # 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. |
上記のメッセージが出ますが、rootで使うだけだったら、いったんログアウトしてログインすればオッケーみたい。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 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 |
インストール。コンパイルするので時間がかかります。
1 2 | # rvm install 2.1.1 # rvm docs generate-ri |
無事にインストールできました。
1 2 3 4 5 6 7 | # 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 |
一般ユーザでもRubyを使う場合は、source /etc/profile.d/rvm.shを実行します。
1 2 3 4 5 6 7 8 9 | $ 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 |
終わり。