2010-06-11 55 views
1

我想使用Rack,FastCGI和Lighttpd運行一個簡單的應用程序,但是我無法實現它的工作。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 
      )) 
      ) 

有人能幫助我嗎?我究竟做錯了什麼?

回答

2

您有一些進程已經在端口80或4000上運行,請使用netstat -anp命令進行檢查。

或者如果系統中沒有netstat,則嘗試將端口更改爲81和/或4001。