views:

186

answers:

2

I'm trying to setup a lighttpd server that will run fastCGI programs written in haskell. So far i got this haskell program:

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

and this lighttpd configuration:

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 starts nicely and works when I open index.html but when I try opening http://127.0.0.1/test it just starts loading the web page and continues loading it indefinitely without showing anything.

I suspect my lighttpd.conf file is either wrong or incomplete but after looking at the documentation I can't find whats wrong with it.

A: 

Your Haskell program looks to me like a CGI script, not a fastCGI script.

Try running it as a CGI script (or even try running it from the command line --- it should output some headers and then your "Hello world" page before terminating).

Dave Hinton
./test.cgi outputs a valid html file.When I modify lighttpd.conf to cgi I just get 404 - Not Found---------------------------------------------------------This is the modified part of lighttpd.conf:--------------------------------------cgi.server = ("/test" => ("test" => ("socket" => "/tmp/test.sock", "bin-path" => "/home/userwww/www/test.cgi", "check-local" => "disable" ) )
lostincomputers
For help on configuring lighttpd, ask on serverfault.com. stackoverflow.com is for programming questions, not configuration questions.
Dave Hinton
+1  A: 

I think you want to use Network.FastCGI instead of Network.CGI. You'll also have to make sure to configure your Haskell program to look in the right place for the socket or listen on the right port.

Amuck