多语言展示
当前在线:1863今日阅读:31今日分享:25

如何在windows10系统下安装ruby on rails

最近需要找一个开源的项目管理工具,需要使用ruby+rails的运行环境,这里介绍如何在windows10系统上安装ruby 2.4和rails web服务器.
工具/原料

windows10

方法/步骤
1

在ruby官方网站上下载windows ruby的应用程序安装包 rubyinstaller

2

运行rubyinstaller-devkit-2.4.4-2-x64.exe应用程序进行安装

3

安装开发软件组件 :MSYS2 and MINGW development toolchain在安装组件对话框中输入选项3,回车后进行安装ruby开发组件

4

在ruby的安装目录下找到Interactive Ruby程序并打开Interactive Ruby默认安装路径:C:\Users\hxb\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Ruby 2.4.4-2-x64 with MSYS2

5

测试ruby语句irb(main):001:0> versionNameError: undefined local variable or method `version' for main:Object        from (irb):1        from C:/Ruby24-x64/bin/irb.cmd:19:in `

'irb(main):002:0> 'hello Ruby world!'=> 'hello Ruby world!'irb(main):003:0> puts 'hello Ruby world!'hello Ruby world!=> nilirb(main):004:0> 4+8=> 12irb(main):005:0> a = 10=> 10irb(main):006:0> a=> 10irb(main):007:0>

6

查看ruby的版本C:\Users\hxb>ruby -vruby 2.4.4p296 (2018-03-28 revision 63013) [x64-mingw32]

7

ruby默认的安装路径C:\Ruby24-x64\bin

8

测试gem安装是否成功在命令行输入gem -v可以看到版本号信息C:\Users\hxb>gem -v2.6.14.1

9

安装rails:C:\Users\hxb>gem install railsC:\Users\hxb>rails -vRails 5.2.1

10

使用rails创建rails web应用helloJackC:\Users\hxb>rails new helloJack      create      create  README.md      create  Rakefile      create  .ruby-version      create  config.ru      create  .gitignore      create  Gemfile         run  git init from '.'      create  package.json...命令执行成功后,会在当前目录下创建helloJack目录以及相关的文件

11

启动rails web服务器C:\Users\hxb\helloJack\bin>rails server=> Booting Puma=> Rails 5.2.1 application starting in G:\ruby-2.4.4=> Run `rails server -h` for more startup optionsconfig.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:  * development - set it to false  * test - set it to false (unless you use a tool that preloads your test environment)  * production - set it to trueRails Error: Unable to access log file. Please ensure that C:/Users/hxb/helloJack/log/G:/ruby-2.4.4.log exists and is writable (ie, make it writable for user and group: chmod 0664 C:/Users/hxb/helloJack/log/G:/ruby-2.4.4.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.*** SIGUSR2 not implemented, signal based restart unavailable!*** SIGUSR1 not implemented, signal based restart unavailable!*** SIGHUP not implemented, signal based logs reopening unavailable!Puma starting in single mode...* Version 3.12.0 (ruby 2.4.4-p296), codename: Llamas in Pajamas* Min threads: 5, max threads: 5* Environment: G:\ruby-2.4.4* Listening on tcp://0.0.0.0:3000

12

在浏览器中输入:http://localhost:3000 就可以看到页面了

推荐信息