2

我正在尝试设置一个 lighttpd 服务器,它将运行用 haskell 编写的 fastCGI 程序。到目前为止,我得到了这个 haskell 程序:

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 文件是错误的或不完整的,但在查看文档后我找不到它有什么问题。

4

2 回答 2

2

我认为您想使用Network.FastCGI而不是 Network.CGI。您还必须确保配置您的 Haskell 程序以在正确的位置查找套接字或侦听正确的端口。

于 2009-12-30T18:29:17.143 回答
1

你的 Haskell 程序在我看来就像一个 CGI 脚本,而不是一个 fastCGI 脚本。

尝试将它作为 CGI 脚本运行(或者甚至尝试从命令行运行它——它应该输出一些标题,然后在终止之前输出你的“Hello world”页面)。

于 2009-12-30T18:13:38.083 回答