Problems with lighty

I’ve been trying to get lighty configured to work with Rails and I’m
having quite a time of it.

I have all of the following installed on a FC4 system:

ruby-1.8.4
gems-0.8.11
rails-1.0
fcgi-2.4.0
ruby-fcgi-0.8.6
lighttpd-1.4.10

Before I tried setting up multiple apps, I just decided to try for a
single app setup. I have the following configuration:

begin config

server.modules = ( “mod_rewrite”, “mod_fastcgi”,
“mod_access”, “mod_accesslog” )
server.indexfiles = ( “dispatch.fcgi”, “index.html” )
accesslog.filename =
“/home/user/fwo/config/lighttpd_access.log”
server.document-root = “/home/user/fwo/public/”
server.error-handler-404 = “/home/user/fwo/public/dispatch.fcgi”
server.errorlog = “/home/user/fwo/log/error.log”

url.rewrite = ( “^/$” => “index.html”, “^([^.]+)$” => “$1.html” )

fastcgi.server = (
“.fcgi” => (
“localhost” => (
“min-procs” => 2,
“max-procs” => 2,
“socket” => “/tmp/rails.socket”,
“bin-path” => “/home/user/fwo/public/dispatch.fcgi”,
“idle-timeout” => 120
)
)
)

end config

The app works perfectly under WEBrick. But with this setup (and I have
tried several others with the same end result) in lighty, I always get
404 errors.

The only time I don’t get a 404 error is if I include this line in
routes.rb:

map.connect ‘/dispatch.fcgi’, :controller => ‘users’, :action =>
‘login_page’

Then it will properly display the page. It will also properly display
any file I have in the public directory. But any time I try the
controller/action URLs, I get a 404. It’s not the 404.html file in
public either, it’s actually a 404 from dispatch.fcgi, or at least it
appears to be.

In error.log, I find:

2006-03-29 04:03:40: (connections.c.1392) Warning: Either the
error-handler retu
rned status 404 or the error-handler itself was not found:
/home/user/fwo/pub
lic/dispatch.fcgi
2006-03-29 04:03:40: (connections.c.1394) returning the original status
404
2006-03-29 04:03:40: (connections.c.1396) If this is a rails app: check
your pro
duction.log

But it can apparently find dispatch.cgi if I reference it directly.
production.log (or in this case, development.log) shows nothing
interesting.

Nevermind, I found the problem.

It appears it was appending the document root path I had specified to
the bin-path variable in the fastcgi server declaration, so it was
looking for:

/home/user/fwo/public/home/user/fwo/public/dispatch.fcgi

I have everything working now.

Jeremy