本文跟大家分享的是在CentOS 7下配置Ruby语言开发环境的方法教程,分享出来供大家参考学习,下面来看看详细的介绍:
安装Ruby 2.2
CentOS7存储库中的Ruby版本为2.0,但如果需要,可以使用RPM软件包安装2.2
1、添加CentOS SCLo软件集合存储库
[root@linuxprobe ~]# yum -y install centos-release-scl-rh centos-release-scl# set [priority=10][root@linuxprobe ~]# sed -i -e "s//]$//]/npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo[root@linuxprobe ~]# sed -i -e "s//]$//]/npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo# for another way, change to [enabled=0] and use it only when needed[root@linuxprobe ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo[root@linuxprobe ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo# if [enabled=0], input a command to use the repository[root@linuxprobe ~]# yum --enablerepo=centos-sclo-rh install [Package][root@linuxprobe ~]# yum --enablerepo=centos-sclo-sclo install [Package]# 安装rubyyum --enablerepo=centos-sclo-rh -y install rh-ruby22
2、软件集合的软件包安装在/opt目录下, 要使用它,需要加载环境变量,如下所示:
# 加载环境变量[root@linuxprobe ~]# scl enable rh-ruby22 bash[root@linuxprobe ~]# ruby -vruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux][root@linuxprobe ~]# which ruby/opt/rh/rh-ruby22/root/usr/bin/ruby
3、设置登录时自动启用Ruby 2.2,按如下所示进行配置:
[root@linuxprobe ~]# vim /etc/profile.d/rh-ruby22.sh#!/bin/bashsource /opt/rh/rh-ruby22/enableexport X_SCLS="`scl enable rh-ruby22 'echo $X_SCLS'`"export PATH=$PATH:/opt/rh/rh-ruby22/root/usr/local/bin
安装Ruby 2.3
# 安装rubyyum --enablerepo=centos-sclo-rh -y install rh-ruby23
1、软件集合的软件包安装在/opt目录下, 要使用它,需要加载环境变量,如下所示:
# 加载环境变量[root@linuxprobe ~]# scl enable rh-ruby23 bash[root@linuxprobe ~]# ruby -vruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux][root@linuxprobe ~]# which ruby/opt/rh/rh-ruby22/root/usr/bin/ruby
2、设置登录时自动启用Ruby 2.3,按如下所示进行配置:
[root@linuxprobe ~]# vim /etc/profile.d/rh-ruby23.sh#!/bin/bashsource /opt/rh/rh-ruby23/enableexport X_SCLS="`scl enable rh-ruby23 'echo $X_SCLS'`"export PATH=$PATH:/opt/rh/rh-ruby23/root/usr/local/bin
安装Ruby on Rails 4来构建Ruby Framework环境
1、添加EPEL软件存储库
[root@linuxprobe ~]# yum -y install epel-release# set [priority=5][root@linuxprobe ~]# sed -i -e "s//]$//]/npriority=5/g" /etc/yum.repos.d/epel.repo# for another way, change to [enabled=0] and use it only when needed[root@linuxprobe ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo# if [enabled=0], input a command to use the repository[root@linuxprobe ~]# yum --enablerepo=epel install [Package]
新闻热点
疑难解答