4rfdf 发表于 2015-8-4 11:02:16

Windows 下的 Apache + FastCGI 部署 ROR 应用

系统需求

[*]Apache
[*]Ruby
[*]Rails
  安装 Ruby 建议使用 Ruby 1.8.6 One-Click Installer,而不要使用 Ruby 1.8.6 Binary ,因为后者不包含 FCGI 模块,即使使用 gem install fcgi 安装也必须编译才能使用。如果没有 FCG 模块,则 Apache 启动 FastCGI 进程可能会报以下错误:
  The pipe has been ended.: mod_fcgid: get overlap result error
  安装 Rails : gem install rails
  安装 Apache Http Server。
  获得 mod_fcgid,该模块依赖 Visual C++ 2008 Redistributable Package;解压 mod_fcgid.so 到 Apache 目录的 modules 子目录下。fcgid 进程默认只有一个 _FCGI_SHUTDOWN_EVENT_ 环境变量,而 Windows DNS 解析必须有一些特定的环境变量,否则会导致无法解析 DNS,应用报以下错误:
  getaddrinfo: no address associated with hostname.
  下面的配置描述了如何解决该问题。
  
  我们这里作一些假设:

[*]ROR 应用目录:D:/WebRoot/redmine/
初始化数据库 :rake db:migrate
  配置 Apache,添加以下脚本:

  LoadModule fcgid_module et/mod/mod_fcgid.so
DefaultInitEnv RAILS_ENV production
# 设置以下环境变量以保证 DNS 解析正确
# 如果不设置,则会报 getaddrinfo: no address associated with hostname.
DefaultInitEnv PATH "C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
DefaultInitEnv SystemRoot "C:/Windows"
DefaultInitEnv SystemDrive "C:"
DefaultInitEnv TEMP "C:/WINDOWS/TEMP"
DefaultInitEnv TMP "C:/WINDOWS/TEMP"
DefaultInitEnv windir "C:/WINDOWS"
  Alias "/redmine" "D:/WebRoot/redmine/public/"
  
Options Indexes ExecCGI FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from All
  
    AddHandler fcgid-script .fcgi
    FCGIWrapper "C:/ruby/bin/ruby.exe D:/WebRoot/redmine/public/dispatch.fcgi" .fcgi
    RewriteEngine on
    RewriteBase /redmine
    RewriteRule ^$ index.html
    RewriteRule ^([^.]+)$ $1.html
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ dispatch.fcgi?$1

2008-5-16 Zealic
页: [1]
查看完整版本: Windows 下的 Apache + FastCGI 部署 ROR 应用