http://blog.163.com/digoal@126/blog/static/1638770402012425111617904/
rvm 全称Ruby Version Manager, 确实是一个非常好用的ruby版本管理以及安装工具.
[root@db-172-16-3-33 ~]# curl -k https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer >./ins
vi ins需要修改两处curl.curl -sk https://api.github.com/repos/wayneeseguin/rvm/tagsif curl -kL ${_url} -o ${rvm_archives_path}/${_file}
[root@db-172-16-3-33 ~]# cat ins|bash -s stable输出结果 :Downloading RVM from wayneeseguin branch stable% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 1023k 100 1023k 0 0 173k 0 0:00:05 0:00:05 --:--:-- 383kInstalling 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
vi ~/.bash_profileexport PATH=/usr/local/rvm/bin:/opt/git1.7.10.2/bin:$PATH更新环境变量.. ~/.bash_profile这里就安装完rvm了
[root@db5 ~]# rvm list help
Usage:
rvm list [action]
Actions:
{help,known,gemsets,default [string],rubies,strings,known_strings,ruby_svn_tags}
[root@db5 ~]# 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-nightly
macruby-head
# IronRuby -- Not implemented yet.
ironruby-0.9.3
ironruby-1.0-rc2
ironruby-head
[root@db5 ~]# rvm install ruby-1.9.3-p194输出Fetching yaml-0.1.4.tar.gz to /usr/local/rvm/archives% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 460k 100 460k 0 0 91728 0 0:00:05 0:00:05 --:--:-- 190kExtracting yaml-0.1.4.tar.gz to /usr/local/rvm/srcPrepare yaml in /usr/local/rvm/src/yaml-0.1.4.Configuring yaml in /usr/local/rvm/src/yaml-0.1.4.Compiling yaml in /usr/local/rvm/src/yaml-0.1.4.Installing yaml to /usr/local/rvm/usrInstalling Ruby from source to: /usr/local/rvm/rubies/ruby-1.9.3-p194, this may take a while depending on your cpu(s)...ruby-1.9.3-p194 - #fetchingruby-1.9.3-p194 - #downloading ruby-1.9.3-p194, this may take a while depending on your connection...% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed.... 略到安装rubygems的时候会出错, 无法获取版本号. 所以需要手工安装rubygems.-- 下载rubygems错误,貌似版本信息没有获取到.Retrieving rubygems-% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (22) The requested URL returned error: 404The requested url does not exist: 'http://production.cf.rubygems.org/rubygems/rubygems-.tgz'Trying ftp:// URL instead.CTRL+C退出-- 手动安装rubygems, 见第3步
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz
tar -zxvf rubygems-1.8.24.tgz
mv rubygems-1.8.24 /usr/local/rvm/src/
cd /usr/local/rvm/src/rubygems-1.8.24-- 由于是rvm管理的ruby环境, 所以在安装rubygems前, 先转到对应的ruby 环境, --default表示设置为默认的ruby环境[root@db-172-16-3-33 rubygems-1.8.24]# rvm use ruby-1.9.3-p194 --defaultUsing /usr/local/rvm/gems/ruby-1.9.3-p194干了什么呢? 弄了个软链接.[root@db5 rubies]# pwd /usr/local/rvm/rubies [root@db5 rubies]# ll total 4.0K lrwxrwxrwx 1 root rvm 37 May 25 10:47 default -> /usr/local/rvm/rubies/ruby-1.9.3-p194 drwxr-xr-x 6 root rvm 4.0K May 25 11:34 ruby-1.9.3-p194-- 安装rubygems[root@db-172-16-3-33 rubygems-1.8.24]# ruby setup.rb输出结果RubyGems 1.8.24 installed== 1.8.24 / 2012-04-27* 1 bug fix:* Install the .pem files properly. Fixes #320* Remove OpenSSL dependency from the http code path------------------------------------------------------------------------------RubyGems installed the following executables:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/gem
[root@db5 ruby-1.9.3-p194]# rvm listrvm rubies=* /usr/local/rvm/scripts/list: line 294: /usr/local/rvm/rubies/ruby-1.9.3-p194/config: No such file or directoryruby-1.9.3-p194 [ ]# => - current# =* - current && default# * - default
rvm reinstall ruby-1.9.3-p194
rvm remove ruby-1.9.3-p194
[root@db5 soft_bak]# gem source --add 'http://ruby.taobao.org/'http://ruby.taobao.org/ added to sources[root@db5 soft_bak]# gem source -l*** CURRENT SOURCES ***http://rubygems.org/http://ruby.taobao.org/
[root@db5 soft_bak]# gem source -usource cache successfully updated
gem query -r -a-- 也可使用规则表达式[root@db5 soft_bak]# gem query -r -n 'redis'*** REMOTE GEMS ***active-redis (0.1.0 ruby)adapter-redis (0.5.1 ruby)bayes_on_redis (0.2.2 ruby)bayes_on_redis_internal (0.0.1 ruby)cache-machine-redis (0.0.1 ruby)cs-em-hiredis (0.1.2 ruby)datalogger-redis (0.0.2 ruby)datastore_redis (0.0.8 ruby)dm-redis-adapter (0.6.2 ruby)dsander-redis (1.0.6 ruby)dsander-redis-store (0.3.8 ruby)easyredis (0.0.6 ruby)em-hiredis (0.1.1 ruby)em-redis (0.3.0 ruby)em-redislite (0.2.2 ruby)eventmachine-redis (0.1.3 ruby)extraloop-redis-storage (0.0.12 ruby)eycloud-recipe-redis (0.2.0 ruby)fakeredis (0.3.1 ruby)faye-redis (0.1.0 ruby)feedzirra-redis (0.1.1 ruby)fluent-plugin-redis (0.2.0 ruby)goncalossilva_redis-session-store (0.1.8.1 ruby)guard-redis (0.1.0 ruby)hiera-redis (0.1.3 ruby)hiera-redis-backend (0.0.1 ruby)hiredis (0.4.5 ruby java java)honkster-redis-store (0.3.16 ruby)i18n_redis (0.0.2 ruby)integration_test_redis (0.0.2 ruby)jashmenn-redis-lock (0.1.1 ruby)joffice_redis (0.1.1 ruby)kali-redis (0.1.1 ruby)mlanett-redis-lock (0.1.1 ruby)mock_redis (0.4.1 ruby)namespaced_redis (1.0.2 ruby)newrelic-redis (1.3.2 ruby)nono-redis-store (1.0.0 ruby)opengotham_redis-namespace (0.4.4 ruby)openid-redis-store (0.0.2 ruby)orm-redis (0.0.0 ruby)qu-redis (0.1.4 ruby)rack-session-redis (0.0.3 ruby)rails3-redis-session-store (0.3.0 ruby)rails_redis_cache (0.2.0 ruby)redis (3.0.0 ruby)redis-actionpack (3.2.3 ruby)redis-activesupport (3.2.3 ruby)redis-aid (0.1.0 ruby)redis-cache (1.0.1 ruby)redis-classy (1.0.2 ruby)redis-column (0.0.3 ruby)redis-connection-ssl (0.0.1 ruby)redis-connection-universal (0.0.1 ruby)redis-diff_match_patch (1.1.1 ruby)redis-dump (0.3.2 ruby)redis-expiring-set (0.1.2 ruby)redis-expiring_counter (1.0.0.0 ruby)redis-friendships (0.2 ruby)redis-health (0.0.1 ruby)redis-i18n (0.6.0 ruby)redis-load (0.2 ruby)redis-lock (0.1.0 ruby)redis-messages (0.1 ruby)redis-mmm (0.1.1 ruby)redis-model (0.1.3 ruby)redis-model-extension (0.3.3 ruby)redis-mutex (1.2.3 ruby)redis-namespace (1.1.0 ruby)redis-native_hash (0.2.1 ruby)redis-objective (0.1.0 ruby)redis-objects (0.5.2 ruby)redis-orm (0.0.4 ruby)redis-persistence (0.0.7 ruby)redis-rack (1.4.1 ruby)redis-rack-cache (1.2 ruby)redis-rails (3.2.3 ruby)redis-repeater (0.2.6 ruby)redis-retry (0.1.0 ruby)redis-roc (0.5.3 ruby)redis-scheduler (0.4 ruby)redis-scripted (0.0.3 ruby)redis-search (0.8.0 ruby)redis-semaphore (0.1.1 ruby)redis-server (0.0.5 ruby)redis-session-store (0.1.9 ruby)redis-settings (0.2.1 ruby)redis-sinatra (1.3.2 ruby)redis-slave (0.0.3 ruby)redis-spawn (0.0.5 ruby)redis-store (1.1.0 ruby)redis-structured-multi (0.0.2 ruby)redis-textsearch (0.2.0 ruby)redis-timeline (0.1.6 ruby)redis-types (0.1.7 ruby)redis-ui (0.1.3 ruby)redis2-session-store (0.0.3 ruby)redis_autocomplete (0.1.4 ruby)redis_buddy (1.0.0 ruby)redis_cache (0.0.1 ruby)redis_cache_mailer_delivery (0.0.6 ruby)redis_directory (1.0.4 ruby)redis_failover (0.8.3 ruby)redis_feature_control (0.0.2 ruby)redis_feed (0.0.1 ruby)redis_geo (0.0.0 ruby)redis_knock (0.0.2 ruby)redis_logger (0.1.0 ruby)redis_master_slave (0.0.1 ruby)redis_on_heroku (0.0.1 ruby)redis_orm (0.6.2 ruby)redis_props (0.3 ruby)redis_record (0.0.1 ruby)redis_resque_initializer (0.0.1 ruby)redis_ring (0.1.3 ruby)redis_ring_client (0.1.2 ruby)redis_selector (0.1.0 ruby)redis_session_store (0.0.2 ruby)redis_snippets (0.0.5 ruby)redis_status (0.1.1 ruby)redis_storage (0.4.0 ruby)redis_store_jr (0.2.1 ruby)redis_support (0.0.18 ruby)redis_throttle (0.1.0 ruby)redis_voteable (0.1.2 ruby)redis_wrapper (0.2.0 ruby)redis_wrapper_rails (0.2.0 ruby)redisarray (0.0.1 ruby)rediscover (0.0.2 ruby)redisearch (0.1.0 ruby)redised (0.2.0 ruby)redish (0.0.1 ruby)redisk (0.2.2 ruby)redislog (1.0.0 ruby)redismapper (0.0.1 ruby)redismodel (0.1.8 ruby)redismq (0.0.6 ruby)redisque (1.0.1 ruby)redisrecord (0.1 ruby)redisrpc (0.3.5 ruby)redistat (0.5.0 ruby)redisted (0.0.2 ruby)redistry (0.1.3 ruby)rspec-redis_helper (0.1.2 ruby)ruby-redis (0.0.2 ruby)ruby-redis-portertech (0.0.3 ruby)ruby_redis_lock (0.1.0 ruby)ruote-redis (2.2.0 ruby)ryansch-mock_redis (0.3.0 ruby)simple-redis-server (0.0.1 ruby)simple_redis_cache (0.0.2 ruby)simredis (0.0.5 ruby)sinatra-redis (0.3.0 ruby)sinatra-redis-auth (0.1.1 ruby)sprockets-cache-redis (0.0.3 ruby)superfeedr-em-redis (0.3.7 ruby)synapse_redis_logger (0.1.0 ruby)tavern-redis (0.0.2 ruby)unified-redis (0.0.2 ruby)uri-redis (0.4.2 ruby)xlymian-redis-store (0.3.8 ruby)yam-redis-with-retries (2.2.2.1 ruby)
[root@db5 ~]# gem help commandsGEM commands are:build Build a gem from a gemspeccert Manage RubyGems certificates and signing settingscheck Check installed gemscleanup Clean up old versions of installed gems in the localrepositorycontents Display the contents of the installed gemsdependency Show the dependencies of an installed gemenvironment Display information about the RubyGems environmentfetch Download a gem and place it in the current directorygenerate_index Generates the index files for a gem server directoryhelp Provide help on the 'gem' commandinstall Install a gem into the local repositorylist Display gems whose name starts with STRINGlock Generate a lockdown list of gemsoutdated Display all gems that need updatesowner Manage gem owners on RubyGems.org.pristine Restores installed gems to pristine condition from fileslocated in the gem cachepush Push a gem up to RubyGems.orgquery Query gem information in local or remote repositoriesrdoc Generates RDoc for pre-installed gemssearch Display all gems whose name contains STRINGserver Documentation and gem repository HTTP serversources Manage the sources and cache file RubyGems uses to searchfor gemsspecification Display gem specification (in yaml)stale List gems along with access timesuninstall Uninstall gems from the local repositoryunpack Unpack an installed gem to the current directoryupdate Update the named gems (or all installed gems) in the localrepositorywhich Find the location of a library file you can requireFor help on a particular command, use 'gem help COMMAND'.Commands may be abbreviated, so long as they are unambiguous.e.g. 'gem i rake' is short for 'gem install rake'.
RVM安装与使用教程
本文详细介绍RVM(Ruby Version Manager)的安装过程及其在CentOS系统中的使用方法,包括解决SSL问题、安装Ruby及Gem的步骤。
639

被折叠的 条评论
为什么被折叠?



