Centos7搭建Ruby环境

先安装gcc环境

yum install gcc-c++

获取密钥

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

获取rvm

curl -sSL https://get.rvm.io | bash -s stable

根据输出的提示执行

source /home/gy/.rvm/scripts/rvm

可以使用rvm命令,列出所有已知源

rvm list known

输出如下

# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.7]
[ruby-]2.4[.4]
[ruby-]2.5[.1]
[ruby-]2.6[.0-preview2]
ruby-head

安装ruby,需要一定时间(好几分钟)

rvm install ruby-2.5.1

切换使用当前版本(有时候不指定的话,gem命令无法识别)

rvm use 2.5.1 default

验证

// 执行命令
ruby -v
// 成功输入如下
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]

执行安装redis与ruby的接口

gem install redis

安装成功提示如下

Fetching: redis-4.0.2.gem (100%)
Successfully installed redis-4.0.2
Parsing documentation for redis-4.0.2
Installing ri documentation for redis-4.0.2
Done installing documentation for redis after 0 seconds
1 gem installed

Centos7搭建Ruby环境

相关推荐