RVM, or Ruby Version Manager is a popular and effective way to manage running multiple Ruby environments. Here is how you set it up on CentOS 5.5:
1) Add the Webtatic respository and install Git.
1
2
|
rpm -Uvh http:
//repo
.webtatic.com
/yum/centos/5/latest
.rpm
yum
install
--enablerepo=webtatic git
|
(Note that this command will also install the perl-Error and perl-Git dependencies)
2) Create an rvm user and group.
1
2
|
groupadd rvm
useradd
-g rvm rvm
|
3) Add the root user to the rvm group (required for installation)
1
|
usermod
-a -G rvm root
|
4) Install RVM as root.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
bash
< <(curl -L http:
//bit
.ly
/rvm-install-system-wide
)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5840 100 5840 0 0 1620 0 0:00:03 0:00:03 --:--:-- 5653
Group
'rvm'
exists, proceeding with installation.
Adding
'root'
to the group
'rvm'
Creating the destination
dir
and making sure the permissions are correct
Cloning into rvm...
remote: Counting objects: 4206,
done
.
remote: Compressing objects: 100% (2029
/2029
),
done
.
Receiving objects: 26% (1094
/4206
), 796.00 KiB | 54 KiB
/s
....
Setting up group permissions
Generating system wide rvmrc
Generating
/usr/local/lib/rvm
to load rvm
Correct permissions on rvmrc and the rvm loader
RVM is now installed. To use,
source
'/usr/local/lib/rvm'
to your shell profile.
|
5) Install zlib via RVM.
1
2
3
4
5
6
7
8
9
|
# rvm package install zlib
Fetching zlib-1.2.5.
tar
.gz to
/usr/local/rvm/archives
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 531k 100 531k 0 0 206k 0 0:00:02 0:00:02 --:--:-- 226k
Extracting zlib-1.2.5.
tar
.gz to
/usr/local/rvm/src
Configuring zlib
in
/usr/local/rvm/src/zlib-1
.2.5.
Compiling zlib
in
/usr/local/rvm/src/zlib-1
.2.5.
Installing zlib to
/usr/local/rvm/usr
|
6) Install Ruby 1.9.2 using RVM.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# rvm install 1.9.2 -C --with-zlib-dir=/usr/local/rvm/src/
Installing Ruby from
source
to:
/usr/local/rvm/rubi
while
depending on your cpu(s)...
ruby-1.9.2-p180 -
#fetching
ruby-1.9.2-p180 -
#extracting ruby-1.9.2-p180 to /u
ruby-1.9.2-p180 -
#extracted to /usr/local/rvm/src/
ruby-1.9.2-p180 -
#configuring
ruby-1.9.2-p180 -
#compiling
ruby-1.9.2-p180 -
#installing
ruby-1.9.2-p180 - Updating
#rubygems to the latest.
Removing old Rubygems files...
Installing rubygems dedicated to ruby-1.9.2-p180...
Installing rubygems
for
/usr/local/rvm/rubies/ruby-1
.9.2-p180
/bin/ruby
Installation of rubygems completed successfully.
ruby-1.9.2-p180 - Updating
#rubygems to the latest.
Removing old Rubygems files...
Installing rubygems dedicated to ruby-1.9.2-p180...
Installing rubygems
for
/usr/local/rvm/rubies/ruby-1
.9.2-p180
/bin/ruby
Installation of rubygems completed successfully.
ruby-1.9.2-p180 - adjusting
#shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.2-p180 -
#importing default gemsets (/usr/local/rvm/gemsets/)
Install of ruby-1.9.2-p180 -
#complete
|
7) Set the RVM default to version 1.9.2
1
2
|
# rvm --default use 1.9.2
Using
/usr/local/rvm/gems/ruby-1
.9.2-p180
|
Verify that Ruby version 1.9.2 was installed successfully.
1
2
|
# ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
|
9) Add this environment variable to root’s .bash_profile file.
1
|
[[ -s
"/usr/local/rvm/scripts/rvm"
]] && .
"/usr/local/rvm/scripts/rvm"
|
10) Install rails.
1
2
3
4
5
6
7
8
|
# gem install rails
Fetching: activesupport-3.0.5.gem (100%)
Fetching: builder-2.1.2.gem (100%)
Fetching: i18n-0.5.0.gem (100%)
...
Installing RDoc documentation
for
railties-3.0.5...
Installing RDoc documentation
for
bundler-1.0.10...
Installing RDoc documentation
for
rails-3.0.5...
|
转自:http://blog.danotes.com/2011/03/16/install-ruby-version-manager-rvm-on-centos-5-5.html