1

我想使用 Rack、FastCGI 和 Lighttpd 运行一个简单的应用程序,但我无法让它工作。

我收到以下错误:

/usr/lib/ruby/1.8/rack/handler/fastcgi.rb:23:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:23:in `new'
from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:23:in `run'
from /www/test.rb:7

这是应用程序:

#!/usr/bin/ruby
app = Proc.new do |env|
        [200, {'Content-Type' => 'text/plain'}, "Hello World!"]
end

require 'rack'
Rack::Handler::FastCGI.run app, :Port => 4000

...和 ​​lighttpd.conf:

server.modules   += ( "mod_access", "mod_accesslog", "mod_fastcgi" )

server.port = 80
server.document-root = "/www"

mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png"
)

index-file.names = ( "test.rb" )

fastcgi.debug = 1
fastcgi.server    = ( ".rb" =>
                ((
                  "host" => "127.0.0.1",
                  "port" => 4000,
                  "bin-path" => "/www/test.rb",
                  "check-local" => "disable",
                  "max-procs" => 1
             ))
            )

有人能帮我吗?我究竟做错了什么?

4

1 回答 1

2

您已经在端口 80 或 4000 上运行了一些进程,请使用netstat -anp命令检查。

或者,如果您的系统上没有 netstat,请尝试将端口更改为 81 和/或 4001。

于 2010-06-13T15:56:51.740 回答