2009-12-30 83 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程序配置为在正确的位置查找套接字或在正确的端口上侦听。