开发者

Rails 3 and FCGI?

I want to make an app for a friend but he has shared hosting and the only option is fcgi and I can't find any d开发者_JAVA技巧ocumentation on how to do it. Is there anyways to run rails 3 on FCGI?


Put in public/whatever.fcgi

#!/usr/bin/ruby

require_relative '../config/environment'

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(YOURAPPNAME::Application)

Check the example app here


Rails 3 is built on top of Rack and Rack provides a FastCGI handler.

  • http://rack.rubyforge.org/doc/
  • http://rack.rubyforge.org/doc/Rack/Handler/FastCGI.html
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜