安裝 rubygems

Gem介紹:

Gem是一個管理Ruby庫和程序的標準包,它通過Ruby Gem(如 http://rubygems.org/ )源來查找、安裝、升級和卸載軟件包,非常的便捷。

Ruby 1.9.2版本默認已安裝Ruby Gem,如果你的版本低於這個?那就往下看吧

安裝gem 需要ruby的版本在 1.8.7 以上,默認的centos5 上都是1.8.5 版本,所以首先你的升級你的ruby ,有兩種方式,yum 和 tar包,

如果你直接用yum的話,一般是裝不上的,得先做些準備,首先添加一個源

ok 如果上面的rpm執行成功,就可以運行下面的yum命令了
yum install ruby ruby-devel rubygems rpm-build
爲了以後不缺這少那 索性就都裝上
裝好以後測試一下
# ruby -v
ruby 1.8.7 (2012-06-29 patchlevel 370) [i386-linux]
ok 已經變成1.8.7 了

現在我們來吧 rubygems安裝上 ,用yum最方便,當然你最好要有 epel 的擴展,什麼你沒裝過,好吧,看下面

  1. CentOS6/RedHat6系列安裝: 
  2.  
  3.     rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm 
  4.  
  5. CentOS5/RedHat5系列安裝: 
  6.  
  7.     rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm 
  8.  
  9. 安裝後編輯epel.repo 
  10.  
  11.     vi /etc/yum.repos.d/epel.repo 
  12.  
  13.     修改 enabled=1 

這個是來源網站 http://www.ppkj.net/2011/08/24/%E9%85%8D%E7%BD%AEepel-yum%E6%BA%90/

上面的執行完成後,就可以安裝了

  1. #yum install rubygems 
  2. ok 測試一下吧 
  3. # /usr/bin/gem install sinatra 
  4. Successfully installed rack-1.5.2 
  5. Successfully installed rack-protection-1.5.0 
  6. Successfully installed tilt-1.3.5 
  7. Successfully installed sinatra-1.3.5 
  8. 4 gems installed 
  9. Installing ri documentation for rack-1.5.2... 
  10. Installing ri documentation for rack-protection-1.5.0... 
  11. Installing ri documentation for tilt-1.3.5... 
  12. Installing ri documentation for sinatra-1.3.5... 
  13. unrecognized option `--encoding=UTF-8' 
  14. For help on options, try 'rdoc --help' 

好了 可以用gem 來安裝ruby的東東了,一般的ruby程序都有 Gemfile,可以用下面的方法把所有需要的東西都裝上,拿 kibana 爲例

 

  1. # cd /soft/Kibana-0.2.0 
  2. # ls Gemfile 
  3. Gemfile 
文件存在,好了,直接執行命令吧
 
  1. # /usr/bin/gem install bundler 
  2. Successfully installed bundler-1.3.4 
  3. 1 gem installed 
  4. Installing ri documentation for bundler-1.3.4... 
  5. Installing RDoc documentation for bundler-1.3.4... 
  6.  
  7. # /usr/bin/bundle
    Fetching gem metadata from http://rubygems.org/.........
    Fetching gem metadata from http://rubygems.org/..
    Resolving dependencies...
    Installing rake (10.0.3)
    Installing daemons (1.1.9)
    Installing diff-lcs (1.1.3)
    Installing eventmachine (1.0.0)
    Installing fastercsv (1.5.5)
    Installing json (1.7.5)
    Installing rack (1.4.1)
    Installing rack-protection (1.2.0)
    Installing tilt (1.3.3)
    Installing sinatra (1.3.3)
    Installing thin (1.5.0)
    Installing tzinfo (0.3.35)
    Using kibana (0.0.1) from source at .
    Installing rspec-core (2.11.1)
    Installing rspec-expectations (2.11.3)
    Installing rspec-mocks (2.11.3)
    Installing rspec (2.11.0)
    Using bundler (1.3.4)
    Your bundle is complete!
    Use `bundle show [gemname]` to see where a bundled gem is installed.
缺少什麼就會補上什麼,完成


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章