2009-12-30 82 views
2

我試圖設置一個lighttpd服務器,它將運行用haskell編寫的fastCGI程序。 到目前爲止,我得到這個哈斯克爾程序:haskell fastcGI on lighttpd,需要配置幫助

import Network.CGI 
import Text.XHtml 

page :: Html 
page = body << h1 << "Hello World!" 

cgiMain :: CGI CGIResult 
cgiMain = output $ renderHtml page 

main :: IO() 
main = runCGI $ handleErrors cgiMain 

這lighttpd的配置:

server.document-root = "/home/userwww/www/" 

server.port = 80 

server.username = "userwww" 
server.groupname = "userwww" 

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

static-file.exclude-extensions = (".php", ".rb", "~", ".inc") 
index-file.names = ("index.html") 
server.event-handler = "poll" 
server.modules    = (
      "mod_access", 
      "mod_accesslog", 
      "mod_fastcgi", 
      "mod_rewrite", 
      "mod_cgi", 
      "mod_auth" 
) 


fastcgi.server = ("/test" => 
        ("test" => 
        ("socket" => "/tmp/test.sock", 
         "bin-path" => "/home/userwww/www/test.fcgi", 
         "check-local" => "disable" 
        ) 
        ) 
       ) 

Lighttpd的很好的開始,當我打開index.html的工作,但是當我嘗試打開http://127.0.0.1/test它只是開始加載網頁,並繼續無限期地加載它,而不顯示任何東西。

我懷疑我的lighttpd.conf文件是錯誤的或不完整的,但在查看文檔後,我找不到它有什麼問題。

回答

1

您的Haskell程序在我看來像一個CGI腳本,而不是fastCGI腳本。

嘗試將其作爲CGI腳本運行(或者甚至嘗試從命令行運行它 - 它應該輸出一些標題,然後在終止之前輸出您的「Hello world」頁面)。

+0

./test.cgi輸出一個有效的html文件。 當我修改lighttpd.conf到CGI我剛剛得到404 - 未找到 -------------------------------- ------------------------- 這是lighttpd.conf的修改部分:------------- ------------------------- cgi.server =(「/ test」=> (「test」=> (「 socket「=>」/tmp/test.sock「, 」bin-path「=>」/home/userwww/www/test.cgi「, 」check-local「=>」disable「 ) ) – lostincomputers 2009-12-30 18:34:56

+0

有關配置lighttpd的幫助,請訪問serverfault.com。stackoverflow.com用於編程問題,而不是配置n個問題。 – dave4420 2009-12-30 19:01:23

2

我想你想用Network.FastCGI而不是Network.CGI。您還必須確保將Haskell程序配置爲在正確的位置查找套接字或在正確的端口上偵聽。