# Lighttpd and fastcgi problems

**URL:** <https://www.ruby-forum.com/t/lighttpd-and-fastcgi-problems/75808>\
**Category:** Rails\
**Created:** [March 2, 2006, 6:31pm UTC](https://www.ruby-forum.com/t/lighttpd-and-fastcgi-problems/75808 "2006-03-02T18:31:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dabeeeenster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@dabeeeenster](https://www.ruby-forum.com/u/dabeeeenster)\
**Post date:** [March 2, 2006, 6:31pm UTC](https://www.ruby-forum.com/t/lighttpd-and-fastcgi-problems/75808/1 "2006-03-02T18:31:34Z")

</div>

Hi,

I’m having difficulty getting ruby running via Lighttpd and fastcgi. My  
lighttpd.conf reads:

server.port = 81  
server.pid-file = “/tmp/test\_lighttpd.pid”

server.modules = ( “mod\_redirect”, “mod\_access”, “mod\_fastcgi”,  
“mod\_accesslog”, “mod\_simple\_vhost” )

server.document-root = “/tmp/mis/public”  
server.indexfiles = ( “index.html” )  
server.error-handler-404 = “/dispatch.fcgi”  
accesslog.filename = “/var/log/lighttpd/access\_log”  
server.errorlog = “/var/log/lighttpd/error\_log”

fastcgi.server = (".fcgi" =\> ( “staging” =\>  
( “min-procs” =\> 1,  
“max-procs” =\> 5,  
“socket” =\> “/tmp/ruby-railsapp.fastcgi”,  
“bin-path” =\> “/tmp/mis/public/dispatch.fcgi”  
)  
))

It serves HTML pages just fine, but when I try and do something ruby, I  
get the following trace:

2006-03-02 17:03:50: (mod\_fastcgi.c.1690) connect failed: Connection  
refused 0 /tmp/ruby-railsapp.fastcgi-1  
2006-03-02 17:03:50: (mod\_fastcgi.c.1690) connect failed: Connection  
refused 0 /tmp/ruby-railsapp.fastcgi-0  
2006-03-02 17:03:51: (mod\_fastcgi.c.2381) unexpected end-of-file  
(perhaps the fastcgi process died): pid: 30409 socket:  
/tmp/ruby-railsapp.fastcgi-0 host: port: 0  
2006-03-02 17:03:51: (mod\_fastcgi.c.3283) response not received, request  
sent: 979 connection-fd: 6 fcgi-fd: 7

Running ls /tmp gives me:

ls /tmp/  
ruby-railsapp.fastcgi-0 ruby-railsapp.fastcgi-1  
ruby-railsapp.fastcgi-2 ruby-railsapp.fastcgi-3  
ruby-railsapp.fastcgi-4 test\_lighttpd.pid

I’ve run out of googling at this point. Can anyone help? I’m running on  
Fedora Core 3 with the latest version of lighttpd:  
/usr/local/sbin/lighttpd -v  
lighttpd-1.4.10 - a light and fast webserver  
Build-Date: Mar 2 2006 16:34:03

and ruby:  
ruby -v  
ruby 1.8.4 (2005-12-24) [i386-linux]

Thanks,  
Ben

---

<div class="post-metadata">

**Author:** ![dabeeeenster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@dabeeeenster](https://www.ruby-forum.com/u/dabeeeenster)\
**Post date:** [March 2, 2006, 6:38pm UTC](https://www.ruby-forum.com/t/lighttpd-and-fastcgi-problems/75808/2 "2006-03-02T18:38:30Z")

</div>

On 3/2/06, Ben R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I’m having difficulty getting ruby running via Lighttpd and fastcgi. My  
> lighttpd.conf reads:  
> Ben

A quick cut and paste from an e-mail I posted a couple of hours ago (I  
did edit it a little to remove some of the old non-elevant context):

=====  
Until you get dispatch.fcgi to properly fail in the absense of a  
webserver I would not even experiment with the webserver.

Try to stop all apache / lighttpd webserver instances and then run  
“ruby dispatch.fcgi”.

AIUI, dispatch.fcgi should be attempting to connect to a socket that  
is provided by the now non-existent webserver. Since the socket does  
not have a listener it should error out with the “Error 500: Internal  
Server Error” message.

If dispatch.fcgi is simply exiting with no error message you still  
have something wrong in your fcgi setup that has nothing to do with  
apache/lighttpd.

At that point you will need to be posting what env. (OS, distro, etc.)  
you are working with and what you did to get your fcgi setup going.  
Getting fcgi setup seems to be very specific to the OS and distro. I  
have only set it up once and that is on a Suse 10.0 setup, so I’m not  
sure I’m the one to help.

# FYI: AIUI, when things are working the webserver creates the sockets and establishes listens on them. Then the fcgi processes are started by the webserver in the background. They in turn connect to the sockets. The fcgi processes should be long lived (hours/days/weeks) and able to handle repeated requests for fcgi service from the webserver.

## HTH Greg

Greg F.  
The Norcross Group  
Forensics for the 21st Century

---

<div class="post-metadata">

**Author:** ![dabeeeenster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@dabeeeenster](https://www.ruby-forum.com/u/dabeeeenster)\
**Post date:** [March 2, 2006, 8:31pm UTC](https://www.ruby-forum.com/t/lighttpd-and-fastcgi-problems/75808/3 "2006-03-02T20:31:16Z")

</div>

In rails edge, changeset 3745 seems to have caused me some issues within  
vendor/rails/activerecord/lib/active\_record/connection\_adapters/abstract/connection\_specification.rb

75: connection.verify!(@@connection\_cache\_timeout)

is giving me grief because I presume I am supposed to have  
@@connection\_cache\_timeout set somewhere.

The latest was checked in today, and I don’t see any other reference of  
@@connection\_cachce\_timeout anywhere.

Does anyone have any ideas?

Cheers, Simon.

---

<div class="post-metadata">

**Author:** ![dabeeeenster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@dabeeeenster](https://www.ruby-forum.com/u/dabeeeenster)\
**Post date:** [March 2, 2006, 11:55pm UTC](https://www.ruby-forum.com/t/lighttpd-and-fastcgi-problems/75808/4 "2006-03-02T23:55:43Z")

</div>

Well, I think I figured out my problem; I needed to install  
ruby-fcgi-0.8.6 with the parameters:

ruby install.rb config – --with-fcgi-include=/usr/local/include  
–with-fcgi-lib=/usr/local/lib

as described in the README, then things started to work.

---

<div class="post-metadata">

**Author:** ![dabeeeenster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@dabeeeenster](https://www.ruby-forum.com/u/dabeeeenster)\
**Post date:** [March 7, 2006, 7:48pm UTC](https://www.ruby-forum.com/t/lighttpd-and-fastcgi-problems/75808/5 "2006-03-07T19:48:25Z")

</div>

Question:

I have lightpd running behind an apache proxy and I would like to  
setup lighttpd so that different folders under webroot are mapped to  
different rails applications.

filesystem view:

webroot/  
railsapp1/  
app/  
config/  
public/  
[…]  
railsapp2/  
app/  
config/  
public/  
[…]

urlview:

[rails.dev.host.com/railsapp1](http://rails.dev.host.com/railsapp1) =\> railsapp1  
[rails.dev.host.com/railsapp2](http://rails.dev.host.com/railsapp2) =\> railsapp2

and

[rails.dev.host.com](http://rails.dev.host.com) =\> index.html in webroot/

Thanks

---

<div class="post-metadata">

**Author:** ![dabeeeenster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@dabeeeenster](https://www.ruby-forum.com/u/dabeeeenster)\
**Post date:** [March 7, 2006, 7:51pm UTC](https://www.ruby-forum.com/t/lighttpd-and-fastcgi-problems/75808/6 "2006-03-07T19:51:27Z")

</div>

see that page:  
[http://www.lighttpd.net/documentation/](http://www.lighttpd.net/documentation/)

and search for keywords ‘virtual’ and ‘host’

---

<div class="post-metadata">

**Author:** ![dabeeeenster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ed655f/32.png) [@dabeeeenster](https://www.ruby-forum.com/u/dabeeeenster)\
**Post date:** [March 7, 2006, 8:34pm UTC](https://www.ruby-forum.com/t/lighttpd-and-fastcgi-problems/75808/7 "2006-03-07T20:34:08Z")

</div>

Thanks Peter,

As I read that page virtual hosting maps hostnames =\> document roots  
(using server-root, default-host, and document-root) – there does not  
appear to be a way to map hostname/path1 to a virtual host.

In order to server two different rails apps I assume that I need to  
create two different fcgi.server blocks in lighttpd.conf however these  
blocks appear to be differentiated based on hostname and port alone.

I can easily map [rails.dev.host.com](http://rails.dev.host.com) to an fcgi process that starts  
either the dispatch.fcgi process in railsapp1 or raqilsapp2.

If I had more control over the name [rails.dev.host.com](http://rails.dev.host.com) I could create  
virtual hosts like this:

[railsapp1.rails.dev.host.com](http://railsapp1.rails.dev.host.com)  
[railsapp2.rails.dev.host.com](http://railsapp2.rails.dev.host.com)

and then create two virtual hosts and two fcgi-server blocks for both  
the apps.

But I am stuck with [rails.dev.host.com](http://rails.dev.host.com)

Perhaps I am missing something obvious …?

> > Datum: Tue, 7 Mar 2006 13:45:08 -0500  
> > railsapp1/  
> > urlview:
> > 
> > - Stephen B.  
> > Concord Consortium, [http://www.concord.org](http://www.concord.org)
> > 
> > * * *
> > 
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–

– Stephen B.  
Director of Technology, Concord Consortium  
10 Concord Crossing, Suite 300, Concord, MA 01742  
direct and fax: 978 405-3209 main: 978 405 3200  
[http://www.concord.org](http://www.concord.org)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
