0
点赞
收藏
分享

微信扫一扫

在windows中安装ruby on rails

梦为马 2022-02-08 阅读 70


在windows中安装ruby on rails_git

​​参考文章​​

和linux一样,首先需要先安装git

使用ruby on rails开发web应用,你需要用到以下四部分


  • ruby
  • rails框架
  • 数据库系统
  • web服务器

web服务器我们可以使用ruby自带的​​WEBrick​

安装ruby就不用多说了,去官网下载安装包并安装就行了

安装rails

gem install rails

执行这条命令时最好挂个代理(你知道我说的这个​​代理​​​是啥意思)在windows中安装ruby on rails_git_02,否则将会耗费很长时间。

中间会出现make的问题,这时需要执行​​ridk install​​,选择第三个,还是需要​​代理​​

注意,ruby版本不要太高,否则在安装nokogiri-1.10.8-x64-mingw32.gem会出现问题,推荐安装ruby2.5

执行​​rails -v​​查看安装是否成功

至此安装成功

我个人比较推荐使用集成化安装

​​访问网站​​

下载安装包并安装,然后打开​​Command Prompt with Ruby and Rails​​​快捷方式,位于​​C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\RailsInstaller​

自带的ruby是2.3.3,如果我们想改成其他版本,可以编辑​​C:\RailsInstaller\Ruby2.3.3\setup_environment.bat​

@ECHO OFF

REM
REM Environment setup file for RailsInstaller.
REM

REM
REM First we determine where is RUBY_DIR (which is where this script is)
REM
PUSHD %~dp0.
SET RUBY_DIR=%CD%
POPD

REM
REM Now determine the RailsInstaller root directory (parent directory of Ruby)
REM
PUSHD %RUBY_DIR%\..
SET ROOT_DIR=%CD%
POPD

REM
REM Add RUBY_DIR\bin to the PATH, DevKit\bin and then Git\cmd
REM RUBY_DIR\bin takes higher priority to avoid other tools conflict
REM
SET PATH=%RUBY_DIR%\bin;%RUBY_DIR%\lib\ruby\gems\1.9.1\bin;%ROOT_DIR%\DevKit\bin;%PATH%
IF EXIST %ROOT_DIR%\Git\cmd SET PATH=%ROOT_DIR%\Git\cmd;%PATH%
SET RUBY_DIR=
SET ROOT_DIR=

REM
REM Create the %HOMEDRIVE%\Sites directory.
REM
IF NOT EXIST %HOMEDRIVE%\Sites MD %HOMEDRIVE%\Sites

REM
REM Set the HOME environment variables for Ruby & Gems to use with ENV["HOME"]
REM
SET HOME=%HOMEDRIVE%%HOMEPATH%

SET RailsInstallerPath=%1
REM Check configurations for Git and SSH
IF EXIST %RailsInstallerPath% (
ruby %RailsInstallerPath%\scripts\config_check.rb
) ELSE (
ruby.exe "require 'rbconfig' ; file=%%\#{RbConfig::}"
)

REM NOTE that we start out in the Sites directory as the current working dir
IF EXIST %HOMEDRIVE%\Sites CD %HOMEDRIVE%\Sites

将​​SET RUBY_DIR=%CD%​​​改为​​SET RUBY_DIR=我们自己安装的ruby的路径​



举报

相关推荐

0 条评论