我正在尝试在 vps 上托管我的 rails 应用程序。我遇到的问题是当我尝试导航到我的 rails 应用程序时,我收到以下错误消息:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
当我查看虚拟服务器的错误日志时,它会告诉我以下信息:
Premature end of script headers:
有时后面会跟着
feed
或 contact
或 referer: myurl.com/
或者什么都没有。我在其他地方看到过很多关于此错误消息的帖子,但到目前为止还没有解决这个问题。普遍的共识似乎是它可能与 rails 环境变量或文件有关。
由于这是我第一次尝试将 Rails 应用程序放在生产服务器上,我认为这是合理的。以下是我的
environment.rb
cat config/environment.rb
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
至于服务器,我使用带有 Webmin/Virtualmin 的 Ubuntu 12.04 和带有乘客的 apache2。 Ruby 2.1.5p273 是使用 RVM 安装的,所有 gem 都是最新的。
任何想法都会有所帮助!
最佳答案
今天我遇到了完全相同的问题。在我的情况下,它是 config/secrets.yml 中的 'secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>' 行(但 env 变量未在服务器上定义)。请查看http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html 的§3.3 .
关于ruby-on-rails - Rails 生产 : Premature end of script headers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27623924/