我尝试在lighttpd上运行rails应用程序,但服务器无法启动,因为fastcgi-backend无法启动。这是lighttpd的错误日志:
2011-08-02 20:43:15: (log.c.166) server started
2011-08-02 20:43:15: (mod_fastcgi.c.1104) the fastcgi-backend /opt/gemeinschaft/public/dispatch.fcgi failed to start:
2011-08-02 20:43:15: (mod_fastcgi.c.1108) child exited with status 13 /opt/gemeinschaft/public/dispatch.fcgi
2011-08-02 20:43:15: (mod_fastcgi.c.1111) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version.
If this is PHP on Gentoo, add 'fastcgi' to the USE flags.
2011-08-02 20:43:15: (mod_fastcgi.c.1399) [ERROR]: spawning fcgi failed.
2011-08-02 20:43:15: (server.c.938) Configuration of plugins failed. Going down.
我的lighttpd.conf看起来像这样:
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_rewrite",
"mod_fastcgi",
"mod_accesslog",
)
server.errorlog = "/var/log/lighttpd/error.log"
accesslog.filename = "/var/log/lighttpd/access.log"
server.document-root = "/var/www"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
index-file.names = (
"index.html",
"index.htm",
)
url.access-deny = ( "~", ".inc", ".htaccess", ".htpasswd" )
static-file.exclude-extensions = ( ".fcgi" )
server.port = 80
include_shell "/usr/share/lighttpd/use-ipv6.pl"
dir-listing.encoding = "utf-8"
server.dir-listing = "disable"
compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = (
"application/x-javascript",
"text/css",
"text/html",
"text/plain",
)
server.reject-expect-100-with-417 = "disable"
# Available since 1.4.21.
# http://redmine.lighttpd.net/wiki/lighttpd/Release-1.4.21
# http://redmine.lighttpd.net/issues/1017
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
$SERVER["socket"] == ":80" {
# "^/((?!(setting|freeswitch)).*)" => "https://%1/$1"
url.rewrite-once = ("^/(setting|freeswitch|manufacturer_snom).*" => "$0",
"^/(.*)" => "/secure/$1")
$HTTP["host"] =~ "(.*)" {
url.redirect = ("^/secure/(.*)" => "https://%1/$1")
}
server.document-root = "/opt/gemeinschaft/public/"
server.error-handler-404 = "/dispatch.fcgi"
fastcgi.server = (
".fcgi" => (
"Gemeinschaft" => (
"socket" => "/tmp/gemeinschaft-fcgi.socket",
"bin-path" => "/opt/gemeinschaft/public/dispatch.fcgi",
"min-procs" => 1,
"max-procs" => 2,
)
)
)
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/ssl/amooma/server.pem"
server.document-root = "/opt/gemeinschaft/public/"
server.error-handler-404 = "/dispatch.fcgi"
fastcgi.server = (
".fcgi" => (
"Gemeinschaft" => (
"socket" => "/tmp/gemeinschaft-fcgi.socket",
"bin-path" => "/opt/gemeinschaft/public/dispatch.fcgi",
"min-procs" => 1,
"max-procs" => 2
)
)
)
#fastcgi.debug = 1
}
这是dispatch.fcgi:
#!/usr/bin/ruby1.9.1
require 'rubygems'
require 'fcgi'
ENV['RAILS_ENV'] ||= 'development'
# Set GEM_PATH and GEM_HOME
#ENV['GEM_PATH'] ||= '/usr/local/rvm/gems/ruby-1.9.2-p290/gems' #'/usr/local/lib/ruby/gems/1.9.1/gems/'
#ENV['GEM_HOME'] ||= '/usr/local/rvm/gems/ruby-1.9.2-p290/gems' #'/usr/local/lib/ruby/gems/1.9.1/gems/'
# Must not be used, otherwise we get a strange error:
# "Could not find rake-0.8.7 in any of the sources".
#require File.join(File.dirname(__FILE__), '../config/environment')
require File.join('/home/ft/programming/Gemeinschaft4/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(
Gemeinschaft4::Application
)
)
像这样运行dispatch.fcgi作为ruby脚本:ruby1.9.1 /path/to/dispatch.fcgi不会产生错误。
当lighttpd.conf中没有bin-path条目时,服务器启动。但每当我添加
"bin-path" => /some/path/dispatch.fcgi
再次出现此错误。
任何提示都将不胜感激。
答案 0 :(得分:0)
我知道我没有直接回答您的问题,但您是否考虑过使用Passenger或Unicorn来运行您的Rails应用程序? Passenger(无论是通过Apache还是Nginx)或Unicorn是更成熟/生产就绪的应用程序环境。