Rack,FastCGI,Lighttpd配置

时间:2010-06-11 13:05:32

标签: ruby fastcgi lighttpd rack

我想使用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
             ))
            )

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

1 个答案:

答案 0 :(得分:2)

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

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