[root@1bf2de961f30 /]# yum install ruby -y
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/4): extras/7/x86_64/primary_db | 247 kB 00:00:00
(3/4): base/7/x86_64/primary_db | 6.1 MB 00:00:06
(4/4): updates/7/x86_64/primary_db | 17 MB 00:00:48
Resolving Dependencies
--> Running transaction check
---> Package ruby.x86_64 0:2.0.0.648-39.el7_9 will be installed
--> Processing Dependency: ruby-libs(x86-64) = 2.0.0.648-39.el7_9 for package: ruby-2.0.0.648-39.el7_9.x86_64
--> Processing Dependency: rubygem(bigdecimal) >= 1.2.0 for package: ruby-2.0.0.648-39.el7_9.x86_64
--> Processing Dependency: ruby(rubygems) >= 2.0.14.1 for package: ruby-2.0.0.648-39.el7_9.x86_64
--> Processing Dependency: libruby.so.2.0()(64bit) for package: ruby-2.0.0.648-39.el7_9.x86_64
--> Running transaction check
---> Package ruby-libs.x86_64 0:2.0.0.648-39.el7_9 will be installed
---> Package rubygem-bigdecimal.x86_64 0:1.2.0-39.el7_9 will be installed
---> Package rubygems.noarch 0:2.0.14.1-39.el7_9 will be installed
--> Processing Dependency: rubygem(rdoc) >= 4.0.0 for package: rubygems-2.0.14.1-39.el7_9.noarch
--> Processing Dependency: rubygem(psych) >= 2.0.0 for package: rubygems-2.0.14.1-39.el7_9.noarch
--> Processing Dependency: rubygem(io-console) >= 0.4.2 for package: rubygems-2.0.14.1-39.el7_9.noarch
--> Running transaction check
---> Package rubygem-io-console.x86_64 0:0.4.2-39.el7_9 will be installed
---> Package rubygem-psych.x86_64 0:2.0.0-39.el7_9 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: rubygem-psych-2.0.0-39.el7_9.x86_64
---> Package rubygem-rdoc.noarch 0:4.0.0-39.el7_9 will be installed
--> Processing Dependency: ruby(irb) = 2.0.0.648 for package: rubygem-rdoc-4.0.0-39.el7_9.noarch
--> Processing Dependency: rubygem(json) >= 1.7.7 for package: rubygem-rdoc-4.0.0-39.el7_9.noarch
--> Running transaction check
---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed
---> Package ruby-irb.noarch 0:2.0.0.648-39.el7_9 will be installed
---> Package rubygem-json.x86_64 0:1.7.7-39.el7_9 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Installing:
ruby x86_64 2.0.0.648-39.el7_9 updates 73 k
Installing for dependencies:
libyaml x86_64 0.1.4-11.el7_0 base 55 k
ruby-irb noarch 2.0.0.648-39.el7_9 updates 94 k
ruby-libs x86_64 2.0.0.648-39.el7_9 updates 2.8 M
rubygem-bigdecimal x86_64 1.2.0-39.el7_9 updates 85 k
rubygem-io-console x86_64 0.4.2-39.el7_9 updates 56 k
rubygem-json x86_64 1.7.7-39.el7_9 updates 82 k
rubygem-psych x86_64 2.0.0-39.el7_9 updates 84 k
rubygem-rdoc noarch 4.0.0-39.el7_9 updates 324 k
rubygems noarch 2.0.14.1-39.el7_9 updates 215 k
Transaction Summary
===========================================================================================================================================================================
Install 1 Package (+9 Dependent packages)
Total download size: 3.8 M
Installed size: 13 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/libyaml-0.1.4-11.el7_0.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for libyaml-0.1.4-11.el7_0.x86_64.rpm is not installed
(1/10): libyaml-0.1.4-11.el7_0.x86_64.rpm | 55 kB 00:00:00
Public key for rubygem-bigdecimal-1.2.0-39.el7_9.x86_64.rpm is not installed
(2/10): rubygem-bigdecimal-1.2.0-39.el7_9.x86_64.rpm | 85 kB 00:00:00
(3/10): rubygem-json-1.7.7-39.el7_9.x86_64.rpm | 82 kB 00:00:00
(4/10): ruby-2.0.0.648-39.el7_9.x86_64.rpm | 73 kB 00:00:00
(5/10): ruby-irb-2.0.0.648-39.el7_9.noarch.rpm | 94 kB 00:00:00
(6/10): rubygem-psych-2.0.0-39.el7_9.x86_64.rpm | 84 kB 00:00:00
(7/10): rubygems-2.0.14.1-39.el7_9.noarch.rpm | 215 kB 00:00:00
(8/10): ruby-libs-2.0.0.648-39.el7_9.x86_64.rpm | 2.8 MB 00:00:00
(9/10): rubygem-rdoc-4.0.0-39.el7_9.noarch.rpm | 324 kB 00:00:00
(10/10): rubygem-io-console-0.4.2-39.el7_9.x86_64.rpm | 56 kB 00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 14 MB/s | 3.8 MB 00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-9.2009.0.el7.centos.x86_64 (@CentOS)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : ruby-libs-2.0.0.648-39.el7_9.x86_64 1/10
Installing : libyaml-0.1.4-11.el7_0.x86_64 2/10
Installing : rubygem-json-1.7.7-39.el7_9.x86_64 3/10
Installing : rubygem-rdoc-4.0.0-39.el7_9.noarch 4/10
Installing : ruby-irb-2.0.0.648-39.el7_9.noarch 5/10
Installing : ruby-2.0.0.648-39.el7_9.x86_64 6/10
Installing : rubygem-bigdecimal-1.2.0-39.el7_9.x86_64 7/10
Installing : rubygem-io-console-0.4.2-39.el7_9.x86_64 8/10
Installing : rubygems-2.0.14.1-39.el7_9.noarch 9/10
Installing : rubygem-psych-2.0.0-39.el7_9.x86_64 10/10
Verifying : libyaml-0.1.4-11.el7_0.x86_64 1/10
Verifying : ruby-2.0.0.648-39.el7_9.x86_64 2/10
Verifying : rubygem-psych-2.0.0-39.el7_9.x86_64 3/10
Verifying : rubygem-rdoc-4.0.0-39.el7_9.noarch 4/10
Verifying : ruby-libs-2.0.0.648-39.el7_9.x86_64 5/10
Verifying : rubygem-json-1.7.7-39.el7_9.x86_64 6/10
Verifying : rubygem-bigdecimal-1.2.0-39.el7_9.x86_64 7/10
Verifying : ruby-irb-2.0.0.648-39.el7_9.noarch 8/10
Verifying : rubygems-2.0.14.1-39.el7_9.noarch 9/10
Verifying : rubygem-io-console-0.4.2-39.el7_9.x86_64 10/10
Installed:
ruby.x86_64 0:2.0.0.648-39.el7_9
Dependency Installed:
libyaml.x86_64 0:0.1.4-11.el7_0 ruby-irb.noarch 0:2.0.0.648-39.el7_9 ruby-libs.x86_64 0:2.0.0.648-39.el7_9 rubygem-bigdecimal.x86_64 0:1.2.0-39.el7_9
rubygem-io-console.x86_64 0:0.4.2-39.el7_9 rubygem-json.x86_64 0:1.7.7-39.el7_9 rubygem-psych.x86_64 0:2.0.0-39.el7_9 rubygem-rdoc.noarch 0:4.0.0-39.el7_9
rubygems.noarch 0:2.0.14.1-39.el7_9
Complete!
[root@1bf2de961f30 /]# ruby -v
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
[root@1bf2de961f30 /]#
可以来提高访问速度
# 查看默认的仓库
[root@1bf2de961f30 /]# gem sources -l
*** CURRENT SOURCES ***
https://rubygems.org/
# 修改为阿里云仓库
[root@1bf2de961f30 /]# gem sources -a http://mirrors.aliyun.com/rubygems/ --remove https://rubygems.org/
http://mirrors.aliyun.com/rubygems/ added to sources
https://rubygems.org/ removed from sources
[root@1bf2de961f30 /]# yum install centos-release-scl-rh
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package centos-release-scl-rh.noarch 0:2-3.el7.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Installing:
centos-release-scl-rh noarch 2-3.el7.centos extras 12 k
Transaction Summary
===========================================================================================================================================================================
Install 1 Package
Total download size: 12 k
Installed size: 20 k
Is this ok [y/d/N]: y
Downloading packages:
centos-release-scl-rh-2-3.el7.centos.noarch.rpm | 12 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : centos-release-scl-rh-2-3.el7.centos.noarch 1/1
Verifying : centos-release-scl-rh-2-3.el7.centos.noarch 1/1
Installed:
centos-release-scl-rh.noarch 0:2-3.el7.centos
Complete!
[root@1bf2de961f30 /]#
[root@1bf2de961f30 /]# yum install rh-ruby26 -y
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* centos-sclo-rh: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package rh-ruby26.x86_64 0:2.6-1.el7 will be installed
--> Processing Dependency: rh-ruby26-runtime for package: rh-ruby26-2.6-1.el7.x86_64
--> Processing Dependency: rh-ruby26-ruby for package: rh-ruby26-2.6-1.el7.x86_64
--> Running transaction check
---> Package rh-ruby26-ruby.x86_64 0:2.6.10-121.el7 will be installed
--> Processing Dependency: rh-ruby26-ruby-libs(x86-64) = 2.6.10-121.el7 for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
--> Processing Dependency: rh-ruby26-ruby(rubygems) >= 3.0.3.1 for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
--> Processing Dependency: rh-ruby26-rubygem(bigdecimal) >= 1.4.1 for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
--> Processing Dependency: rh-ruby26-rubygem(did_you_mean) >= 1.3.0 for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
--> Processing Dependency: rh-ruby26-rubygem(io-console) >= 0.4.7 for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
--> Processing Dependency: rh-ruby26-rubygem(json) >= 2.1.0 for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
--> Processing Dependency: rh-ruby26-rubygem(openssl) >= 2.1.2 for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
--> Processing Dependency: rh-ruby26-rubygem(psych) >= 3.1.0 for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
--> Processing Dependency: rh-ruby26-rubygem(rdoc) >= 6.1.2.1 for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
--> Processing Dependency: libruby.so.2.6()(64bit) for package: rh-ruby26-ruby-2.6.10-121.el7.x86_64
---> Package rh-ruby26-runtime.x86_64 0:2.6-1.el7 will be installed
--> Running transaction check
---> Package rh-ruby26-ruby-libs.x86_64 0:2.6.10-121.el7 will be installed
---> Package rh-ruby26-rubygem-bigdecimal.x86_64 0:1.4.1-121.el7 will be installed
---> Package rh-ruby26-rubygem-did_you_mean.noarch 0:1.3.0-121.el7 will be installed
---> Package rh-ruby26-rubygem-io-console.x86_64 0:0.4.7-121.el7 will be installed
---> Package rh-ruby26-rubygem-json.x86_64 0:2.1.0-121.el7 will be installed
---> Package rh-ruby26-rubygem-openssl.x86_64 0:2.1.2-121.el7 will be installed
---> Package rh-ruby26-rubygem-psych.x86_64 0:3.1.0-121.el7 will be installed
---> Package rh-ruby26-rubygem-rdoc.noarch 0:6.1.2.1-121.el7 will be installed
--> Processing Dependency: rh-ruby26-rubygem(irb) = 1.0.0 for package: rh-ruby26-rubygem-rdoc-6.1.2.1-121.el7.noarch
---> Package rh-ruby26-rubygems.noarch 0:3.0.3.1-121.el7 will be installed
--> Running transaction check
---> Package rh-ruby26-rubygem-irb.noarch 0:1.0.0-121.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================
Installing:
rh-ruby26 x86_64 2.6-1.el7 centos-sclo-rh 2.5 k
Installing for dependencies:
rh-ruby26-ruby x86_64 2.6.10-121.el7 centos-sclo-rh 79 k
rh-ruby26-ruby-libs x86_64 2.6.10-121.el7 centos-sclo-rh 3.0 M
rh-ruby26-rubygem-bigdecimal x86_64 1.4.1-121.el7 centos-sclo-rh 92 k
rh-ruby26-rubygem-did_you_mean noarch 1.3.0-121.el7 centos-sclo-rh 77 k
rh-ruby26-rubygem-io-console x86_64 0.4.7-121.el7 centos-sclo-rh 59 k
rh-ruby26-rubygem-irb noarch 1.0.0-121.el7 centos-sclo-rh 99 k
rh-ruby26-rubygem-json x86_64 2.1.0-121.el7 centos-sclo-rh 82 k
rh-ruby26-rubygem-openssl x86_64 2.1.2-121.el7 centos-sclo-rh 179 k
rh-ruby26-rubygem-psych x86_64 3.1.0-121.el7 centos-sclo-rh 88 k
rh-ruby26-rubygem-rdoc noarch 6.1.2.1-121.el7 centos-sclo-rh 451 k
rh-ruby26-rubygems noarch 3.0.3.1-121.el7 centos-sclo-rh 311 k
rh-ruby26-runtime x86_64 2.6-1.el7 centos-sclo-rh 25 k
Transaction Summary
===========================================================================================================================================================================
Install 1 Package (+12 Dependent packages)
Total download size: 4.5 M
Installed size: 14 M
Downloading packages:
(1/13): rh-ruby26-2.6-1.el7.x86_64.rpm | 2.5 kB 00:00:00
(2/13): rh-ruby26-ruby-2.6.10-121.el7.x86_64.rpm | 79 kB 00:00:00
(3/13): rh-ruby26-rubygem-bigdecimal-1.4.1-121.el7.x86_64.rpm | 92 kB 00:00:00
(4/13): rh-ruby26-rubygem-did_you_mean-1.3.0-121.el7.noarch.rpm | 77 kB 00:00:00
(5/13): rh-ruby26-rubygem-io-console-0.4.7-121.el7.x86_64.rpm | 59 kB 00:00:00
(6/13): rh-ruby26-rubygem-irb-1.0.0-121.el7.noarch.rpm | 99 kB 00:00:00
(7/13): rh-ruby26-ruby-libs-2.6.10-121.el7.x86_64.rpm | 3.0 MB 00:00:00
(8/13): rh-ruby26-rubygem-json-2.1.0-121.el7.x86_64.rpm | 82 kB 00:00:00
(9/13): rh-ruby26-rubygem-openssl-2.1.2-121.el7.x86_64.rpm | 179 kB 00:00:00
(10/13): rh-ruby26-rubygem-psych-3.1.0-121.el7.x86_64.rpm | 88 kB 00:00:00
(11/13): rh-ruby26-rubygem-rdoc-6.1.2.1-121.el7.noarch.rpm | 451 kB 00:00:00
(12/13): rh-ruby26-runtime-2.6-1.el7.x86_64.rpm | 25 kB 00:00:00
(13/13): rh-ruby26-rubygems-3.0.3.1-121.el7.noarch.rpm | 311 kB 00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 7.6 MB/s | 4.5 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : rh-ruby26-runtime-2.6-1.el7.x86_64 1/13
Installing : rh-ruby26-ruby-libs-2.6.10-121.el7.x86_64 2/13
Installing : rh-ruby26-rubygem-did_you_mean-1.3.0-121.el7.noarch 3/13
Installing : rh-ruby26-rubygem-openssl-2.1.2-121.el7.x86_64 4/13
Installing : rh-ruby26-rubygem-irb-1.0.0-121.el7.noarch 5/13
Installing : rh-ruby26-rubygem-psych-3.1.0-121.el7.x86_64 6/13
Installing : rh-ruby26-rubygem-io-console-0.4.7-121.el7.x86_64 7/13
Installing : rh-ruby26-rubygem-json-2.1.0-121.el7.x86_64 8/13
Installing : rh-ruby26-rubygems-3.0.3.1-121.el7.noarch 9/13
Installing : rh-ruby26-rubygem-bigdecimal-1.4.1-121.el7.x86_64 10/13
Installing : rh-ruby26-rubygem-rdoc-6.1.2.1-121.el7.noarch 11/13
Installing : rh-ruby26-ruby-2.6.10-121.el7.x86_64 12/13
Installing : rh-ruby26-2.6-1.el7.x86_64 13/13
Verifying : rh-ruby26-rubygem-bigdecimal-1.4.1-121.el7.x86_64 1/13
Verifying : rh-ruby26-ruby-libs-2.6.10-121.el7.x86_64 2/13
Verifying : rh-ruby26-rubygem-did_you_mean-1.3.0-121.el7.noarch 3/13
Verifying : rh-ruby26-rubygem-openssl-2.1.2-121.el7.x86_64 4/13
Verifying : rh-ruby26-rubygem-irb-1.0.0-121.el7.noarch 5/13
Verifying : rh-ruby26-rubygem-psych-3.1.0-121.el7.x86_64 6/13
Verifying : rh-ruby26-runtime-2.6-1.el7.x86_64 7/13
Verifying : rh-ruby26-2.6-1.el7.x86_64 8/13
Verifying : rh-ruby26-ruby-2.6.10-121.el7.x86_64 9/13
Verifying : rh-ruby26-rubygems-3.0.3.1-121.el7.noarch 10/13
Verifying : rh-ruby26-rubygem-rdoc-6.1.2.1-121.el7.noarch 11/13
Verifying : rh-ruby26-rubygem-io-console-0.4.7-121.el7.x86_64 12/13
Verifying : rh-ruby26-rubygem-json-2.1.0-121.el7.x86_64 13/13
Installed:
rh-ruby26.x86_64 0:2.6-1.el7
Dependency Installed:
rh-ruby26-ruby.x86_64 0:2.6.10-121.el7 rh-ruby26-ruby-libs.x86_64 0:2.6.10-121.el7 rh-ruby26-rubygem-bigdecimal.x86_64 0:1.4.1-121.el7
rh-ruby26-rubygem-did_you_mean.noarch 0:1.3.0-121.el7 rh-ruby26-rubygem-io-console.x86_64 0:0.4.7-121.el7 rh-ruby26-rubygem-irb.noarch 0:1.0.0-121.el7
rh-ruby26-rubygem-json.x86_64 0:2.1.0-121.el7 rh-ruby26-rubygem-openssl.x86_64 0:2.1.2-121.el7 rh-ruby26-rubygem-psych.x86_64 0:3.1.0-121.el7
rh-ruby26-rubygem-rdoc.noarch 0:6.1.2.1-121.el7 rh-ruby26-rubygems.noarch 0:3.0.3.1-121.el7 rh-ruby26-runtime.x86_64 0:2.6-1.el7
Complete!
[root@1bf2de961f30 /]#
# 临时加载环境变量
[root@1bf2de961f30 /]# scl enable rh-ruby26 bash
[root@1bf2de961f30 /]# ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [x86_64-linux]
[root@1bf2de961f30 /]#
因为上面添加的环境变量是临时的,重启以后就不再生效,为了一直生效,需添加环境变量配置。
创建配置文件rh-ruby26.sh
vim /etc/profile.d/rh-ruby26.sh
#!/bin/bash
source /opt/rh/rh-ruby26/enable
export X_SCLS="`scl enable rh-ruby26 'echo $X_SCLS'`"
export PATH=$PATH:/opt/rh/rh-ruby26/root/usr/local/bin