本文跟大家分享的是在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]

# 安装ruby

yum --enablerepo=centos-sclo-rh -y install rh-ruby22

2、软件集合的软件包安装在/opt目录下, 要使用它,需要加载环境变量,如下所示:

# 加载环境变量

[root@linuxprobe ~]# scl enable rh-ruby22 bash

[root@linuxprobe ~]# ruby -v

ruby 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/bash

source /opt/rh/rh-ruby22/enable

export X_SCLS="`scl enable rh-ruby22 'echo $X_SCLS'`"

export PATH=$PATH:/opt/rh/rh-ruby22/root/usr/local/bin

安装Ruby 2.3

# 安装ruby

yum --enablerepo=centos-sclo-rh -y install rh-ruby23

1、软件集合的软件包安装在/opt目录下, 要使用它,需要加载环境变量,如下所示:

# 加载环境变量

[root@linuxprobe ~]# scl enable rh-ruby23 bash

[root@linuxprobe ~]# ruby -v

ruby 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/bash

source /opt/rh/rh-ruby23/enable

export 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]

Ruby on Rails 4

1、安装Ruby 2.2,参考上面

2、安装依赖包(epel+SCLo)

[root@linuxprobe ~]# yum --enablerepo=epel,centos-sclo-rh -y install rh-ruby22-ruby-devel nodejs libuv gcc make libxml2 libxml2-devel mariadb-devel zlib-devel libxslt-devel

安装Rails 4

[root@linuxprobe ~]# gem install bundler

[root@linuxprobe ~]# gem install nokogiri -- --use-system-libraries

[root@linuxprobe ~]# gem install rails --version="~>4.0" --no-ri --no-rdoc

[root@linuxprobe ~]# /opt/rh/rh-ruby22/root/usr/local/bin/rails -v

Rails 4.2.8

Ruby on Rails 5

1、安装Ruby 2.3,参考上面

2、安装依赖包(epel+SCLo)

[root@linuxprobe ~]# yum --enablerepo=epel,centos-sclo-rh -y install rh-ruby23-ruby-devel nodejs libuv gcc make libxml2 libxml2-devel mariadb-devel zlib-devel libxslt-devel

安装Rails 5

[root@linuxprobe ~]# gem install bundler

[root@linuxprobe ~]# gem install nokogiri -- --use-system-libraries

[root@linuxprobe ~]# gem install rails --no-ri --no-rdoc

[root@linuxprobe ~]# rails -v

Rails 5.0.2

创建一个示例应用程序,并确保其正常工作

1、需要安装MariaDB服务

[root@linuxprobe ~]# yum -y install mariadb-server

[root@linuxprobe ~]# vi /etc/my.cnf

# add follows within [mysqld] section

[mysqld]

character-set-server=utf8

[root@linuxprobe ~]# systemctl start mariadb

[root@linuxprobe ~]# systemctl enable mariadb

ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

2、初始化MariaDB

[root@linuxprobe ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user. If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

# set root password

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

# remove anonymous users

Remove anonymous users? [Y/n] y

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

# disallow root login remotely

Disallow root login remotely? [Y/n] y

... Success!

By default, MariaDB comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

# remove test database

Remove test database and access to it? [Y/n] y

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

# reload privilege tables

Reload privilege tables now? [Y/n] y

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

# connect to MariaDB with root

[root@linuxprobe ~]# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 11

Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# show user list

MariaDB [(none)]> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host | password |

+------+-----------+-------------------------------------------+

| root | localhost | *E2ACEC2F2DA384EE6753673365DFEF35F0C272C9 |

| root | 127.0.0.1 | *E2ACEC2F2DA384EE6753673365DFEF35F0C272C9 |

| root | ::1 | *E2ACEC2F2DA384EE6753673365DFEF35F0C272C9 |

+------+-----------+-------------------------------------------+

3 rows in set (0.00 sec)

# show database list

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

MariaDB [(none)]> exit

Bye

3、创建测试应用程序

[root@linuxprobe ~]# gem install mysql2 --no-ri --no-rdoc -- --with-mysql-config=/usr/bin/mysql_config

[root@linuxprobe ~]# rails new SampleApp -d mysql

[root@linuxprobe ~]# cd SampleApp

[root@linuxprobe SampleApp]# vi config/database.yml

default: &default

adapter: mysql2

encoding: utf8

pool: 5

username: root

password: password # MariaDB password

socket: /var/lib/mysql/mysql.sock

# create test application

[root@dlp SampleApp]# rails db:create

Created database 'SampleApp_development'

Created database 'SampleApp_test'

[root@dlp SampleApp]# rails generate scaffold testapp name:string title:string body:text

[root@dlp SampleApp]# rails db:migrate

[root@dlp SampleApp]# rails server --binding=0.0.0.0

=> Booting Puma

=> Rails 5.0.2 application starting in development on http://0.0.0.0:3000

=> Run `rails server -h` for more startup options

Puma starting in single mode...

* Version 3.8.2 (ruby 2.3.1-p112), codename: Sassy Salamander

* Min threads: 5, max threads: 5

* Environment: development

* Listening on tcp://0.0.0.0:3000

Use Ctrl-C to stop

4、客户端访问http://10.1.1.53:3000/

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对脚本之家的支持。

yum安装ruby_CentOS 7下配置Ruby语言开发环境的方法教程相关推荐

  1. agx 安装ros opencv_Linux下配置深度学习开发环境(及ros)

    平台选择上,直接用linux系统最好,其次选择双系统,最后考虑虚拟机,vm有时候会莫名其妙挂掉, VirtualBox显存太小. 机器人操作系统,ROS的安装直接参照官网,报错忽略,最后就能用.很多教 ...

  2. Eclipse下搭建C语言开发环境

    Eclipse下搭建C语言开发环境 要使用Eclipse开发C/C++语言主要有 下面几个步骤: 1. 安装 JRE 去sun官方网站 下载安装即可 由于 Eclipse 本身是用 Java 开发的, ...

  3. VS Code配置Go语言开发环境

    VS Code配置Go语言开发环境 Go语言是采用UTF8编码的,理论上使用任何文本编辑器都能做Go语言开发.大家可以根据自己的喜好自行选择.编辑器/IDE没有最好只有最适合 1.安装中文简体插件 点 ...

  4. CentOS 7 配置JS语言开发环境(JavaScript)

    CentOS 7 配置JS语言开发环境(JavaScript) 安装ServerSide JavaScript环境"Node.js" 安装Node.js和包管理工具npm [roo ...

  5. windows 下配置 react native 开发环境

    windows 下配置 react native 开发环境 安装nvm 由于react native 需要使用 NodeJs 4.0以上版本,为了方便切换NodeJs,首先我们需要安装nvm. 你可以 ...

  6. vscode怎么配置python运行环境f5_VSCode下配置python调试运行环境的方法_python

    这篇文章主要介绍了VSCode下配置python调试运行环境的方法,需要的朋友可以参考下 VSCode配置python调试环境 很久之前的一个东东,翻出来看看VSCode配置python调试环境 * ...

  7. Linux搭建部落冲突,GitHub - lioyou/nvim-coc: 在Win10上使用WSL安装Ubuntu,并安装neovim+coc.nvim,配置多种语言开发环境......

    在windows上使用Ubuntu并配置多种语言开发境 0 效果 使用C++ 1 开启WSL服务并安装Ubuntu 自己利用搜索引擎去查找相关资料并安装,很容易的就两步 2 安装各类编程语言的相关依赖 ...

  8. Ubuntu 配置 Go 语言开发环境(Sublime Text+GoSublime)

    本文针对的 Go 语言版本为 1.3,之前也有相关文章讲解如何在 Ubuntu 下配置Go语言的开发环境,但时过境迁,一些方法已经不相同或者不必要.虽讲的是 Ubuntu 下安装配置过程,但 Wind ...

  9. 轻松玩转树莓派Pico之三、Windows+Ubuntu虚拟机模式下VSCode C语言开发环境搭建

    目录 1.VSCode下载与安装 2.VSCode基础插件安装 3.SSH连接与配置 4.SSH免密登录 5.Pico编译 工欲善其事,必先利其器.之前的介绍的Pico流程都是通过命令行编译,没有进行 ...

最新文章

  1. 列表自定义的Type和BaseType参考
  2. 大文件分片上传,断点续传,秒传 实现
  3. JZOJ 5257. 小X的佛光
  4. git个人使用总结 —— idea命令行、撤销commit (未完待续)
  5. zz数字图像的结课报告
  6. 利用python脚本(re)抓取美空mm图片
  7. ajax respon有数据,Ajax怎么通过response在后台传递数据?(附代码)
  8. sql实现对多个条件分组排序方法和区别
  9. 小米、QQ等8款手机浏览器发布自查整改公告;AMD宣布收购赛灵思;​TypeScript 4.0.5发布|极客头条
  10. 姆巴佩独造三球一战成名 阿里云打破世界杯流量纪录
  11. 普通人学python有啥用-普通人为什么要学习Python
  12. 环境管理体系ISO14001认证常见的审核问题有哪些?
  13. womic网络错误_无线麦克风WO Mic
  14. 【知识点】patch补丁文件格式
  15. SpringCloud-Gateway网关
  16. 5G+智慧矿山系统如何降低开发成本
  17. 上海东方美谷JW万豪、福清喜来登、宁波杭州湾凯悦等酒店开业 | 中国酒店周刊...
  18. b、B、kb、kB单位
  19. 前端学习第八弹:制作一个精美书签
  20. lbaas l7 policy

热门文章

  1. 刚才看到一篇文章,感觉不错,转载过来和大家分享:
  2. JSP手机商城系统设计网站
  3. 【论文写作】客户端设计与实现中模块程序实现如何写
  4. docker中linux用户名密码,linuxea:尽可能不在docker镜像中嵌入配置或者密码
  5. proxool mysql 配置 useunicode_proxool + MySQL + servelt 的使用
  6. 致谢计算机组成原理老师的致谢,计算机组成原理课程报告(40页)-原创力文档...
  7. 【JZOJ5911】Travel
  8. Unity3D调用android方法(非插件方式)
  9. SQL SERVER LEFT JOIN, INNER JOIN, RIGHT JOIN
  10. Runtime.getRuntime().exec()----记录日志案例