出現的問題:
[root@localhost ~]# gem install redis
Fetching: redis-4.0.1.gem (100%)
ERROR: Error installing redis:
redis requires Ruby version >= 2.2.2.<br>php
緣由:ruby版本過低,要求2.2.2版本+
解決:安裝rbuy高版本
須要用rvm 來安裝rubylinux
[root@localhost ~]# gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 gpg: keyring `/root/.gnupg/secring.gpg' created gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net gpg: /root/.gnupg/trustdb.gpg: trustdb created gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported gpg: no ultimately trusted keys found gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) [root@localhost ~]# \curl -sSL https://get.rvm.io | bash -s stable Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz curl: (52) Empty reply from server Could not download 'https://github.com/rvm/rvm/archive/1.29.3.tar.gz'. curl returned status '52'. Downloading https://bitbucket.org/mpapis/rvm/get/1.29.3.tar.gz Downloading https://bitbucket.org/mpapis/rvm/downloads/1.29.3.tar.gz.asc gpg: Signature made Mon 11 Sep 2017 04:59:29 AM CST using RSA key ID BF04FF17 gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>" gpg: aka "Michal Papis <michal.papis@toptal.com>" gpg: aka "[jpeg image of size 5015]" gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3 Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36 166B E206 C29F BF04 FF17 GPG verified '/usr/local/rvm/archives/rvm-1.29.3.tgz' Creating group 'rvm' Installing RVM to /usr/local/rvm/ Installation of RVM in /usr/local/rvm/ is almost complete: * First you need to add all users that will be using rvm to 'rvm' group, and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`. * To start using RVM you need to run `source /etc/profile.d/rvm.sh` in all your open shell windows, in rare cases you need to reopen all shell windows. [root@localhost ~]# source /etc/profile.d/rvm.sh [root@localhost ~]# rvm -v rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
查詢rvm庫中ruby的版本git
[root@localhost ~]# 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[.7] [ruby-]2.3[.4] [ruby-]2.4[.1] ruby-head # for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2 # JRuby jruby-1.6[.8] jruby-1.7[.27] jruby[-9.1.13.0] jruby-head # Rubinius rbx-1[.4.3] rbx-2.3[.0] rbx-2.4[.1] rbx-2[.5.8] rbx-3[.84] rbx-head # Opal opal # Minimalistic ruby implementation - ISO 30170:2012 mruby-1.0.0 mruby-1.1.0 mruby-1.2.0 mruby-1[.3.0] mruby[-head] # Ruby Enterprise Edition ree-1.8.6 ree[-1.8.7][-2012.02] # Topaz topaz # MagLev maglev[-head] maglev-1.0.0 # Mac OS X Snow Leopard Or Newer macruby-0.10 macruby-0.11 macruby[-0.12] macruby-nightly macruby-head # IronRuby ironruby[-1.1.3] ironruby-head
安裝最新的2.4版本rubygithub
[root@localhost ~]# rvm install 2.4 Searching for binary rubies, this might take some time. Found remote file https://rvm_io.global.ssl.fastly.net/binaries/centos/7/x86_64/ruby-2.4.1.tar.bz2 Checking requirements for centos. Installing requirements for centos. Installing required packages: patch, autoconf, automake, bison, bzip2, libffi-devel, libtool, patch, readline-devel, sqlite-devel, zlib-devel, li............... Requirements installation successful. ruby-2.4.1 - #configure ruby-2.4.1 - #download % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 14.1M 100 14.1M 0 0 117k 0 0:02:02 0:02:02 --:--:-- 121k No checksum for downloaded archive, recording checksum in user configuration. ruby-2.4.1 - #validate archive ruby-2.4.1 - #extract ruby-2.4.1 - #validate binary ruby-2.4.1 - #setup ruby-2.4.1 - #gemset created /usr/local/rvm/gems/ruby-2.4.1@global ruby-2.4.1 - #importing gemset /usr/local/rvm/gemsets/global.gems.............................. ruby-2.4.1 - #generating global wrappers........ ruby-2.4.1 - #gemset created /usr/local/rvm/gems/ruby-2.4.1 ruby-2.4.1 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list ruby-2.4.1 - #generating default wrappers........
切換使用2.4版本rubyredis
[root@localhost ~]# rvm use 2.4 Using /usr/local/rvm/gems/ruby-2.4.1
移除2.0.0 版本rubysql
[root@localhost ~]# rvm remove 2.0.0 ruby-2.0.0-p648 - #already gone Using /usr/local/rvm/gems/ruby-2.4.1
驗證ruby版本shell
[root@localhost ~]# ruby -v ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]