我遇到了以下问题:在我的主机 (www.site5.com) 上,ruby 相当旧 - 1.8.7,服务器在 Apache 下运行,Phusion Passenger 用于部署。支持团队安装了一个 RVM,这样我就可以使用 ruby 1.9.3。然而,即使安装一个最简单的 rails 应用程序,服务器报告
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
问题在于配置我在这里展示的 dispatch.fcgi 和 .htaccess 文件:
调度.fcgi
#!/home/foo/.rvm/rubies/ruby-1.9.3-p392/bin/ruby
ENV['RAILS_ENV'] ||= 'production'
ENV['HOME'] ||= `echo ~`.strip
ENV['GEM_HOME'] = File.expand_path('~/.rvm/gems/ruby-1.9.3-p392')
ENV['GEM_PATH'] = File.expand_path('~/.rvm/gems/ruby-1.9.3-p392') + ":" +
File.expand_path('~/.rvm/gems/ruby-1.9.3-p392@global')
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(try::Application)
.htaccess
AddHandler application/x-httpd-php52 .php
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
</IfModule>
Options +FollowSymLinks +ExecCGI
#Change to your environment
RailsEnv production
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule .* - [L]
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
支持团队努力,但到目前为止我们还没有找到出路……