使用rvm在rails上调度dispatch.fcgi和ruby

时间:2012-01-12 15:27:41

标签: ruby-on-rails ruby-on-rails-3 fastcgi

我试图获得一个'#34; hello world"应用程序使用 rvm 在我的托管服务(Dreamhost)上工作。我使用 rvm 以便我可以使用Ruby 1.9.2和Rails 3.1

我认识到有更好的托管环境和更好的方法来做到这一点,但是现在我想我会努力努力并努力使这项工作。

我有一个cgi脚本工作,显示rvm似乎正常工作:http://rails.hortitude.com/foo.cgi

#!/usr/bin/env /home/hortitude/.rvm/bin/ruby-1.9.2-p290

puts "Content-Type: text/html"
puts
puts "<html>"
puts "<body>"
puts "<h1>Hello Ruby!</h1>"
puts "<p>shebang: #!/usr/bin/env /home/hortitude/.rvm/bin/ruby-1.9.2-p290</p>"
puts "<p>RUBY_VERSION: " + RUBY_VERSION + "</p>"
puts "<p>RUBY_PLATFORM: " + RUBY_PLATFORM + "</p>"
puts "<p> RUBY_RELEASE_DATE: " + RUBY_RELEASE_DATE + "</p>"
puts "</body>"
puts "</html>"
puts "</html>"

但是,我的dispatch.fcgi脚本总是给我一个错误(在错误日志中找到)

  

脚本标题的提前结束:dispatch.fcgi

这是我的dispatch.fcgi脚本:

#!/usr/bin/env /home/hortitude/.rvm/bin/ruby-1.9.2-p290

ENV['GEM_HOME'] ||= '/home/hortitude/.rvm/gems/ruby-1.9.2-p290'

require 'rubygems'
require 'fcgi'

ENV['RAILS_ENV'] ||= 'production'

# Set GEM_PATH and GEM_HOME ("user" is your dreamhost user)
##ENV['GEM_HOME'] ||= '/home/user/.gems'

require 'rubygems'
Gem.clear_paths


require File.join(File.dirname(__FILE__), '../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(Helloworld::Application)

0 个答案:

没有答案