Gem是一個管理Ruby庫和程序的標準包,它經過Ruby Gem(如 http://rubygems.org/ )源來查找、安裝、升級和卸載軟件包,很是的便捷。linux
Ruby 1.9.2版本默認已安裝Ruby Gem,若是你的版本低於這個?那就往下看吧sql
安裝gem 須要ruby的版本在 1.8.7 以上,默認的centos5 上都是1.8.5 版本,因此首先你的升級你的ruby ,有兩種方式,yum 和 tar包,json
若是你直接用yum的話,通常是裝不上的,得先作些準備,首先添加一個源centos
- CentOS6/RedHat6系列安裝:
- rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
- CentOS5/RedHat5系列安裝:
- rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
- 安裝後編輯epel.repo
- vi /etc/yum.repos.d/epel.repo
- 修改 enabled=1
這個是來源網站 http://www.ppkj.net/2011/08/24/%E9%85%8D%E7%BD%AEepel-yum%E6%BA%90/ruby
上面的執行完成後,就能夠安裝了ide
- #yum install rubygems
- ok 測試一下吧
- # /usr/bin/gem install sinatra
- Successfully installed rack-1.5.2
- Successfully installed rack-protection-1.5.0
- Successfully installed tilt-1.3.5
- Successfully installed sinatra-1.3.5
- 4 gems installed
- Installing ri documentation for rack-1.5.2...
- Installing ri documentation for rack-protection-1.5.0...
- Installing ri documentation for tilt-1.3.5...
- Installing ri documentation for sinatra-1.3.5...
- unrecognized option `--encoding=UTF-8'
- For help on options, try 'rdoc --help'
好了 能夠用gem 來安裝ruby的東東了,通常的ruby程序都有 Gemfile,能夠用下面的方法把全部須要的東西都裝上,拿 kibana 爲例
- # cd /soft/Kibana-0.2.0
- # ls Gemfile
- Gemfile
文件存在,好了,直接執行命令吧
- # /usr/bin/gem install bundler
- Successfully installed bundler-1.3.4
- 1 gem installed
- Installing ri documentation for bundler-1.3.4...
- Installing RDoc documentation for bundler-1.3.4...
- # /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.缺乏什麼就會補上什麼,完成