Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 documentation on how to do it. Is there anyways to run rails 3 on FCGI?

like image 921
BiscottiLighter Avatar asked Jul 21 '10 03:07

BiscottiLighter


1 Answers

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

like image 66
Ivailo Bardarov Avatar answered Nov 10 '22 02:11

Ivailo Bardarov