CentOS7下安裝Ruby3.2.4的實(shí)施路徑詳解
一、CentOS版本
[user@zt ~]$ cat /etc/os-release NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"
二、先安裝RVM
RVM是一個(gè)linux下的Ruby的多版本管理工具,可以維護(hù)多個(gè)Ruby版本,切換版本。對(duì)于開(kāi)發(fā)Ruby應(yīng)用程序比較友好。還有個(gè)優(yōu)點(diǎn)就是不需要梯子,對(duì)于國(guó)內(nèi)用戶友好。
安裝GPG的key,用于身份驗(yàn)證
$ gpg2 --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
安裝RVM最新穩(wěn)定版本
$ \curl -sSL https://get.rvm.io | bash -s stable
三、安裝Ruby的前置依賴
更新gcc版本,默認(rèn)為4.8.5版本,最好升級(jí)到7以上版本,我們這里升級(jí)到了9版本,升級(jí)gcc版需要先更新yum源
$ yum install centos-release-scl -y
安裝完成后在 /etc/yum.repos.d 目錄下會(huì)出現(xiàn) CentOS-SCLo-scl.repo 和 CentOS-SCLo-scl-rh.repo 兩個(gè)文件,安裝后源默認(rèn)啟用,但是坑也就是在這里被埋下了。CentOS 7 最晚在 2024年6月30后 停止更新維護(hù),在此之前在 CentOS 7 可以通過(guò) yum 直接安裝 SCL 源基本都是可以正常使用的。這個(gè)時(shí)候需要更新源的地址:
$ vi /etc/yum.repos.d/CentOS-SCLo-scl.repo
修改此部分的baseurl為阿里云源
[centos-sclo-sclo] name=CentOS-7 - SCLo sclo baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/ # mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
$ vi /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
修改此部分的baseurl為阿里云源
[centos-sclo-rh] name=CentOS-7 - SCLo rh baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/ # mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
最后刷新緩存
yum repolist yum clean all yum makecache
正式升級(jí)gcc版本
yum install devtoolset-9-gcc* -y
顯示如下即安裝成功:
Installed:
devtoolset-9-gcc.x86_64 0:9.3.1-2.2.el7 devtoolset-9-gcc-c++.x86_64 0:9.3.1-2.2.el7 devtoolset-9-gcc-gdb-plugin.x86_64 0:9.3.1-2.2.el7 devtoolset-9-gcc-gfortran.x86_64 0:9.3.1-2.2.el7 devtoolset-9-gcc-plugin-devel.x86_64 0:9.3.1-2.2.el7Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 devtoolset-9-binutils.x86_64 0:2.32-16.el7 devtoolset-9-libquadmath-devel.x86_64 0:9.3.1-2.2.el7 devtoolset-9-libstdc++-devel.x86_64 0:9.3.1-2.2.el7
devtoolset-9-runtime.x86_64 0:9.1-0.el7 gmp-devel.x86_64 1:6.0.0-15.el7 libgfortran5.x86_64 0:8.3.1-2.1.1.el7 libmpc-devel.x86_64 0:1.0.1-3.el7 libquadmath.x86_64 0:4.8.5-44.el7
libsemanage-python.x86_64 0:2.5-14.el7 mpfr-devel.x86_64 0:3.1.1-4.el7 policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7Complete!
啟用新版gcc
scl enable devtoolset-9 bash
查看gcc版本:
gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
使當(dāng)前的終端立即生效:
source /opt/rh/devtoolset-9/enable
四、安裝指定版本的Ruby
CC=/opt/rh/devtoolset-9/root/usr/bin/gcc rvm install 3.2.4
顯示如下即表示安裝成功:
ruby-3.2.4 - #removing src/ruby-3.2.4.. Searching for binary rubies, this might take some time. No binary rubies available for: centos/7/x86_64/ruby-3.2.4. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for centos. Requirements installation successful. Installing Ruby from source to: /usr/local/rvm/rubies/ruby-3.2.4, this may take a while depending on your cpu(s)... ruby-3.2.4 - #downloading ruby-3.2.4, this may take a while depending on your connection... ruby-3.2.4 - #extracting ruby-3.2.4 to /usr/local/rvm/src/ruby-3.2.4..... ruby-3.2.4 - #configuring.................................................................. ruby-3.2.4 - #post-configuration.. ruby-3.2.4 - #compiling................................................................................................... ruby-3.2.4 - #installing..................................... ruby-3.2.4 - #making binaries executable... Installed rubygems 3.4.19 is newer than 3.0.9 provided with installed ruby, skipping installation, use --force to force installation. ruby-3.2.4 - #gemset created /usr/local/rvm/gems/ruby-3.2.4@global ruby-3.2.4 - #importing gemset /usr/local/rvm/gemsets/global.gems................................................................ ruby-3.2.4 - #generating global wrappers........ ruby-3.2.4 - #gemset created /usr/local/rvm/gems/ruby-3.2.4 ruby-3.2.4 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list ruby-3.2.4 - #generating default wrappers........ ruby-3.2.4 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake). Install of ruby-3.2.4 - #complete Ruby was built without documentation, to build it run: rvm docs generate-ri
查看RVM使用的當(dāng)前Ruby版本
rvm list =* ruby-3.2.4 [ x86_64 ] # => - current # =* - current && default # * - default
到此這篇關(guān)于CentOS7下安裝Ruby3.2.4的實(shí)施路徑的文章就介紹到這了,更多相關(guān)CentOS7安裝Ruby3.2.4內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
在Mac OS X下安裝Ruby運(yùn)行環(huán)境的詳細(xì)步驟
這篇文章主要給大家介紹了在Mac OS X下安裝Ruby運(yùn)行環(huán)境的方法步驟,文中介紹的很詳細(xì),相信對(duì)大家具有一定的參考價(jià)值,需要的朋友們下面來(lái)一起看看吧。2017-02-02print不自動(dòng)換行,puts會(huì)自動(dòng)換行
print不自動(dòng)換行,puts會(huì)自動(dòng)換行...2007-10-10Ruby實(shí)現(xiàn)的一個(gè)強(qiáng)大的批量刪除文件腳本分享
這篇文章主要介紹了Ruby實(shí)現(xiàn)的一個(gè)強(qiáng)大的批量刪除文件腳本分享,本文腳本實(shí)現(xiàn)對(duì)指定目錄下的文件根據(jù)最后修改時(shí)間刪除文件,需要的朋友可以參考下2015-01-01