Centos7 install ruby

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

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

    It may wait for more than ten seconds, and then execute the following command:

1

~]# \curl -sSL https://get.rvm.io | bash -s stable

    

    ~]# 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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325123764&siteId=291194637