转自http://my.oschina.net/u/1449160/blog/260764
1
. 安装ruby
1
.
1
yum安装,版本旧
#yum install ruby ruby-devel ruby-ri ruby-rdoc ruby-irb ruby-shadow
1
.
2
删除
#yum remove ruby ruby-devel -y
1
.
3
源码安装
#wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz
#tar zxvf ruby-2.1.1.tar.gz
#cd ruby-2.1.1
#./configure --prefix=/usr/local/ruby --with-opessl-dir=/root/soft/openssl-1.0.0l
#make && make install
#echo "export PATH=/usr/local/ruby/bin:$PATH >> /root/.bash_profile"
#source /root/.bash_profile
#ruby --version
ruby
2
.
1
.1p76 (
2014
-
02
-
24
revision
45161
) [x86_64-linux]
2
.安装gem并更新gem源
2
.
1
如果存在更新为最新的RubyGems,
#gem update --system
如果版本过旧,
#gem install rubygems-update
#update_rubygems
2
.
2
源码安装
#wget http://production.cf.rubygems.org/rubygems/rubygems-2.2.2.tgz
#tar zxvf rubygems-2.2.2.tgz
#cd rubygems-2.2.2
#ruby setup.rb
#gem --version
2
.
3
更换gem源为淘宝
#gem sources --remove https://rubygems.org/
#gem sources -a https://ruby.taobao.org/
#gem sources -l
***
CURRENT
SOURCES
***
https://ruby.taobao.org/
如果是用Bundle(Rails 项目)
#source ‘https://ruby.taobao.org/‘
#gem ‘rails‘, ‘4.1.0‘
附:gem sources -a https://ruby.taobao.org/报错
ERROR
: While executing gem ... (Gem::
Exception
)
Unable to require openssl, install OpenSSL
and
rebuild ruby (preferred)
or
use non-
HTTPS
sources
需要指定openssl目录(源码)。
3
. 测试安装Mongodb driver
for
ruby
# gem install bson
# gem install bson_ext
# gem install mongo
# gem list --local
...
bson (
2
.
2
.
2
,
1
.
10
.
0
)
bson_ext (
1
.
10
.
0
)
...
mongo (
1
.
10
.
0
)
# irb
irb(main):
001
:
0
> require
‘mongo‘
=>
true