我有一个IIS 8.5服务器设置已经用于开发PHP和JSP应用程序,我现在想在rails支持上添加ruby。
我已经使用railsinstaller来安装ruby,并在rails v4程序上运行 rails new [appname] 来创建应用程序。该应用程序不包括dispatch.cgi所以我抓住了以下网络。
ENV['RAILS_ENV'] = 'production'
ENV['HOME'] ||= `echo ~`.strip
ENV['GEM_HOME'] = File.expand_path('~/.gems')
ENV['GEM_PATH'] = File.expand_path('~/.gems')
require 'fcgi'
require File.join(File.dirname(__FILE__), '../config/environment.rb')
flog = File.open('fastcgi.log', 'a+')
STDOUT.reopen flog
STDERR.reopen flog
STDOUT.sync = true
STDERR.sync = true
class Rack::PathInfoRewriter
def initialize(app)
@app = app
end
def call(env)
env.delete('SCRIPT_NAME')
parts = env['REQUEST_URI'].split('?')
env['PATH_INFO'] = parts[0]
env['QUERY_STRING'] = parts[1].to_s
@app.call(env)
end
end
Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(Sampleapp::Application)
我还创建了* .fcgi的映射处理程序来运行ruby.exe。我现在遇到的问题是因为rails没有附带fcgi模块所以“require'fcgi'”失败了。实际错误如下......
HTTP Error 500.0 - Internal Server Error
C:\RailsInstaller\Ruby1.9.3\bin\ruby.exe - The FastCGI process exited unexpectedly
从命令行运行它我得到以下
c:\inetpub\rails\railsapp\public>ruby dispatch.fcgi
C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:
36:in `require': cannot load such file -- fcgi (LoadError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
from dispatch.fcgi:7:in `<main>'
c:\inetpub\rails\railsapp\public>
那么如何为rails安装缺少的fcgi x64模块,或以其他方式让它运行?