我在共享的Dreamhost服務器上安裝了ruby 2.1.2和rails 4.1.5。我成功地通過遵循this guide設法使用fcgi部署了一個裸機應用程序。然後我嘗試部署一個我以前使用capistrano 3開發的應用程序。cap production deploy
工作正常,rails console production
也是如此。使用fcgi將rails應用程序部署調試到Dreamhost
問題是,每當我嘗試去我的應用程序的網址,我得到一個500錯誤,只是說「Rails應用程序未能正常啓動」。我嘗試了以下this other guide進行故障排除,但我並沒有走得太遠。
至於我可以告訴大家,我的公開/ dispatch.fcgi文件似乎是工作的罰款:
#!/home/myuser/.ruby/bin/ruby
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')
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(MyApp::Application)
我試圖運行文件本身,我只能得到一個提示,沒有錯誤(這似乎意味着該應用程序是好的)。
我的日誌/ production.log文件是空的。我的服務器日誌只顯示幾行無用消息[Mon Sep 01 17:45:14 2014] [error] [client 201.246.73.121] Premature end of script headers: dispatch.fcgi
,它至少告訴我dispatch.fcgi正在被調用。只有谷歌搜索告訴我,我可能會丟失的fcgi
寶石,但事實並非如此:
$ bundle show fcgi
/home/myuser/.gems/gems/fcgi-0.9.2.1
以防萬一,這是我的Gemfile,不包括測試和生產environmens:
source 'https://rubygems.org'
ruby '2.1.2'
gem 'therubyracer'
gem 'fcgi'
gem 'mysql'
gem 'rails', '4.1.2'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'bootstrap-sass'
gem 'high_voltage'
gem 'slim-rails'
gem 'savon', '~> 2.5.1'
gem 'spreadsheet', '~> 0.9.7'
任何如何調試這個想法? 謝謝
我剛剛碰到這個確切的問題,有沒有任何解決方案? – chills42 2014-11-10 04:19:12