安装
yum -y install ruby rubygems
查看版本
ruby --version
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
由于centos 系统默认支持Ruby版本为2.0.0 ,因此执行gem install redis 命令时会报以下错误。
[[email protected] src]# gem install redis
Fetching: redis-4.0.1.gem (100%)
ERROR: Error installing redis:
redis requires Ruby version >= 2.2.2.
解决方法是先安装rvm ,再升级ruby 版本。
curl -sSL https://get.rvm.io | bash -s stable
结果出现以下错误:
Downloading https://github.com/rvm/rvm/archive/1.29.7.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc
gpg: Signature made Fri 04 Jan 2019 06:01:48 AM CST using RSA key ID 39499BDB
gpg: Can't check signature: No public key
GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.29.7.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.7/1.29.7.tar.gz.asc'! Try to install GPG v2 and then fetch the public key:
gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
or if it fails:
command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
In case of further problems with validation please refer to https://rvm.io/rvm/security
安装rvm出现公钥问题
根据提示,预先执行:
gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
再执行安装
OK完美解决
然后执行以下命令。
source /usr/local/rvm/scripts/rvm
查看rvm库中已知的ruby版本
rvm list known
例如:
升级Ruby
#安装ruby
rvm install 2.4.0
#使用新版本
rvm use 2.4.0
#移除旧版本
rvm remove 2.0.0
#查看当前版本
ruby --version
完成
|
请发表评论