一聚教程网:一个值得你收藏的教程网站

热门教程

CentOS 7 编译安装ruby的方法

时间:2022-06-30 20:49:10 编辑:袖梨 来源:一聚教程网


安装步骤。

[root@DS-VM-Node190 /tmp/]# mkdir -p /tmp/ruby
[root@DS-VM-Node190 /tmp]# DOWNLOAD_URL="http://mirrors.dwhd.org/Ruby/ruby" &&
DOWNLOAD_URL="$(curl -Lks "${DOWNLOAD_URL}"|awk -PF'"' '{if ($2~/^[0-9]+.[0-9]+/)a=$2}END{print "'$DOWNLOAD_URL'/"a}')" &&
DOWNLOAD_URL="$(curl -s "${DOWNLOAD_URL}"|awk -PF'"' '{if ($2~/^ruby.*xz$/)a=$2}END{print "'$DOWNLOAD_URL'"a}')"
# 也可以直接用官方地址
#  DOWNLOAD_URL="https://cache.ruby-lang.org/pub/ruby" &&
#  DOWNLOAD_URL="$(curl -Lks "${DOWNLOAD_URL}"|awk -PF'"' '{if ($2~/^[0-9]+.[0-9]+/)a=$2}END{print "'$DOWNLOAD_URL'/"a}')" &&
#  DOWNLOAD_URL="$(curl -s "${DOWNLOAD_URL}"|awk -PF'"' '{if ($2~/^ruby.*xz$/)a=$2}END{print "'$DOWNLOAD_URL'"a}')"
[root@DS-VM-Node190 /tmp]# curl -Lk $DOWNLOAD_URL | tar -xJ -C /tmp/ruby --strip-components=1
[root@DS-VM-Node190 /tmp]# cd /tmp/ruby/
[root@DS-VM-Node190 /tmp/ruby]# yum install -y zlib-devel openssl-devel #如果不安装这两个扩展包,后面还是很麻烦的
[root@DS-VM-Node190 /tmp/ruby]# ./configure --prefix=/usr/local --disable-install-rdoc
[root@DS-VM-Node190 /tmp/ruby]# make -j $(awk '/processor/{i++}END{print i}' /proc/cpuinfo) && make install && cd && rm -rf /tmp/ruby
[root@DS-VM-Node190 ~]# ruby -v
ruby 2.4.0preview1 (2016-06-20 trunk 55466) [x86_64-linux]
[root@DS-VM-Node190 ~]#

热门栏目