コレグレーデギネード

WindowsとかUbuntuとかRubyとかRailsとか

RVM マルチユーザインストール

最新記事はこちら
さくらのVPS + Ubuntu + RVM + Ruby 2.0.0-p0 + Rails 3.2.12 + Apache2 + Passenger インストール - コレグレーデギネード


サーバ運用上、RVM(Ruby)はマルチユーザインストールが望ましい。
本家サイトRVM: Ruby Version Manager - Installing RVM

RVM本体のインストール bashの前にsudoを入れるだけ。

$ curl -L get.rvm.io | sudo bash -s stable
[sudo] password for mainuser:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   185  100   185    0     0    340      0 --:--:-- --:--:-- --:--:--  1434
100  9249  100  9249    0     0   5389      0  0:00:01  0:00:01 --:--:--     0

Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0    128      0 --:--:-- --:--:-- --:--:--   177
100 1045k  100 1045k    0     0   188k      0  0:00:05  0:00:05 --:--:--  309k

Installing RVM to /usr/local/rvm/
    Creating RVM system user group 'rvm'

# RVM:  Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.io/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm/
# Screencast: http://screencasts.org/episodes/how-to-use-rvm

# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'

Installation of RVM in /usr/local/rvm/ is almost complete:

  * 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 g+w`.

  * 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,
#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne

rvm 1.14.1 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

一旦ログアウトしてから再度ログイン。

$ rvm -v
rvm 1.14.1 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

インストールされていることが確認できる。

必要なパッケージを確認。

$ rvm requirements

Requirements for Linux ( DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS" )

NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
             This is the *original* / standard Ruby Language Interpreter
      'ree'  represents Ruby Enterprise Edition
      'rbx'  represents Rubinius

bash >= 4.1 required
curl is required
git is required (>= 1.7 for ruby-head)
patch is required (for 1.8 rubies and some ruby-head's).

To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
then you must install and use rvm 1.8.7 first.

Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
  ruby: /usr/bin/apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

# For JRuby, install the following:
  jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
  jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk

# For IronRuby, install the following:
  ironruby: /usr/bin/apt-get install curl mono-2.0-devel

For Rubyにあるパッケージをすべてaptでインストール。

$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool

インストールできるRubyを一覧で確認。

$ rvm list known

# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p358]
[ruby-]1.8.7-head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2-p180
[ruby-]1.9.2-p290
[ruby-]1.9.2-p318
[ruby-]1.9.2[-p320]
[ruby-]1.9.2-head
[ruby-]1.9.3-preview1
[ruby-]1.9.3-rc1
[ruby-]1.9.3-p0
[ruby-]1.9.3-p125
[ruby-]1.9.3[-p194]
[ruby-]1.9.3-head
ruby-head

# GoRuby
goruby

# TheCodeShop - MRI experimental patches
tcs

# JRuby
jruby-1.2.0
jruby-1.3.1
jruby-1.4.0
jruby-1.6.5
jruby-1.6.5.1
jruby-1.6.6
jruby-1.6.7
jruby[-1.6.7.2]
jruby-head
jruby-1.7.0.preview1

# Rubinius
rbx-1.0.1
rbx-1.1.1
rbx-1.2.3
rbx-1.2.4
rbx[-head]
rbx-2.0.testing

# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]

# Kiji
kiji

# MagLev
maglev[-head]
maglev-1.0.0

# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby[-0.11]
macruby-nightly
macruby-head

# IronRuby -- Not implemented yet.
ironruby-0.9.3
ironruby-1.0-rc2
ironruby-head

rvmsudoコマンドでRuby(Version1.8.7-head)をインストールする。

$ rvmsudo rvm install 1.8.7-head
[sudo] password for mainuser:

Installing Ruby from source to: /usr/local/rvm/rubies/ruby-1.8.7-head, this may take a while depending on your cpu(s)...

ruby-1.8.7-head - #fetching 
Cloning from git://github.com/ruby/ruby.git, this may take a while depending on your connection...
Cloning into '/usr/local/rvm/repos/ruby'...
remote: Counting objects: 227443, done.
remote: Compressing objects: 100% (45648/45648), done.
remote: Total 227443 (delta 180731), reused 225138 (delta 179993)
Receiving objects: 100% (227443/227443), 76.77 MiB | 269 KiB/s, done.
Resolving deltas: 100% (180731/180731), done.
HEAD is now at 0d92aac * process.c (rb_fork_err): Fix the conditoin to use rb_protect.
Checking out files: 100% (3739/3739), done.
Branch ruby_1_8_7 set up to track remote branch ruby_1_8_7 from origin.
Switched to a new branch 'ruby_1_8_7'
Copying from repo to src path...
Applying patch 'stdout-rouge-fix' (located at /usr/local/rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch)
Applying patch 'no_sslv2' (located at /usr/local/rvm/patches/ruby/1.8.7/no_sslv2.diff)
ruby-1.8.7-head - #autoreconf
ruby-1.8.7-head - #configuring 
ruby-1.8.7-head - #compiling 
ruby-1.8.7-head - #installing 
Retrieving rubygems-1.8.24
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  371k  100  371k    0     0   485k      0 --:--:-- --:--:-- --:--:-- 1028k
Extracting rubygems-1.8.24 ...
Removing old Rubygems files...
Installing rubygems-1.8.24 for ruby-1.8.7-head ...
Installation of rubygems completed successfully.
ruby-1.8.7-head - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.8.7-head - #importing default gemsets (/usr/local/rvm/gemsets/)
Install of ruby-1.8.7-head - #complete 
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to Ruby 1.9.3-194 which will have all of the latest security patches.

RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal settings to allow shell login.
Please visit https://rvm.io/workflow/screen/ for example.

Ruby Version1.9.3-headも同じようにインストール。

$ rvmsudo rvm install 1.9.3-head

インストール完了後、Rubyを確認。

$ rvm list

rvm rubies

   ruby-1.8.7-head [ i686 ]
   ruby-1.9.3-head [ i686 ]

# Default ruby not set. Try 'rvm alias create default <ruby>'.

# => - current
# =* - current && default
#  * - default

Ruby Version デフォルト設定。

$ rvmsudo rvm alias create default ruby-1.9.3-head
$ rvm use ruby-1.9.3-head

マルチユーザインストールの場合/usr/local/rvm/に格納される。

$ which rvm ruby gem
/usr/local/rvm/bin/rvm
/usr/local/rvm/rubies/ruby-1.9.3-head/bin/ruby
/usr/local/rvm/rubies/ruby-1.9.3-head/bin/gem