lighttpd 无法启动 fastcgi 后端。我该如何解决这个问题?

发布于 2024-11-27 08:08:56 字数 4910 浏览 3 评论 0原文

我尝试在lighttpd 上运行rails 应用程序,但服务器无法启动,因为fastcgi 后端无法启动。这是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脚本运行,如下所示: ruby​​1.9.1 /path/to/dispatch.fcgi 不会产生错误。
当 lighttpd.conf 中没有 bin-path 条目时,服务器启动。但是每当我添加

"bin-path" => /some/path/dispatch.fcgi

这个错误时就会再次出现。
任何提示将不胜感激。

I try to run a rails app on a lighttpd, but the server does not start because the fastcgi-backend fails to start. This is the error log of 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.

My lighttpd.conf looks like this:

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
}

And here is the 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
  )
)

running the dispatch.fcgi as ruby script like this: ruby1.9.1 /path/to/dispatch.fcgi produces no error.
when there is no bin-path entry in lighttpd.conf the server starts. But whenever i add

"bin-path" => /some/path/dispatch.fcgi

this error occurs again.
Any hint would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雾里花 2024-12-04 08:08:56

我知道我不会直接回答您的问题,但是您是否考虑过使用 Passenger 或 Unicorn 来运行 Rails 应用程序? Passenger(无论是通过 Apache 还是 Nginx)或 Unicorn 是更加成熟/生产就绪的应用程序环境。

I understand I am not answering your question directly, but have you considered using Passenger or Unicorn to run your Rails app? The Passenger (whether via Apache or Nginx) or Unicorn are much more established / production ready application environments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文