Environment requirements : In Centos7.3, the version of ruby installed through yum is 2.0.0, but if some applications require a higher version of ruby environment, such as 2.2, 2.3, 2.4...
I searched the Internet and found the following three methods:
①Add yum source installation: CentOS SCLo Software collections Repository (simple and fast)
②Download the tar archive and install it (slightly cumbersome)
③RVM (Ruby Version Manager) installation (relatively official)
Specific operation :
Method 1 : Change the yum source installation
~]# yum install centos-release-scl-rh //There will be an extra CentOS-SCLo-scl-rh.repo source in the /etc/yum.repos.d/ directory
~]# yum install rh-ruby23 -y //You can install it directly with yum
~]# scl enable rh-ruby23 bash //Necessary step
~]# ruby -v //View the installed version
Continued : continue with the error report mentioned above: " redis requires Ruby version >= 2.2.2 "
~]# gem install redis
Then, the binary file redis-trib.rb can be used to build a redis cluster. For related content, please refer to the previous article, see Method 2.
Method 2 : Download the tar archive and install it
$ ./configure
$ make
$ sudo make install
Method 3 : RVM installation
First execute a long command copied from the official https://rvm.io/ (...C0E3 space 7D2B...):
1 |
|
It may wait for more than ten seconds, and then execute the following command:
1 |
|
~]# source /etc/profile.d/rvm.sh //Follow the prompts to execute the command
~]# rvm list known // List the versions that can be installed
~]# rvm install 2.4.1 // Install ruby 2.4.1, just follow the version number
~]# ruby -v //View the installed version under verification
~]# gem -v
At this point, the ruby installation is complete