Linux之CentOS 7 编译安装高版本ruby

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

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

lookback

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: