Trac with FastCGI on lighttpd doesn't work: connect failed: Connection refused on unix:/tmp/trac-fastcgi.sock-3

1,026 views
Skip to first unread message

Michael Schmarck

unread,
Jun 4, 2008, 3:42:49 AM6/4/08
to Trac Users Mailinglist
Good morning!

I installed Trac 0.11dev on a Solaris 10 Sparc system
and would like to use it with FastCGI under lighttpd 1.4.19.

To do so, I added the following to the lighttpd.conf:

############################################################ Trac:
server.modules += ("mod_alias")
alias.url = ("/trac/chrome/common" =>
"/export/home/webservd/trac/Trac-0.11dev/trac/htdocs")

$HTTP["url"] =~ "^/trac(?!/chrome/common)" {
fastcgi.server = ("/trac" =>
("trac" =>
("socket" => "/tmp/trac-fastcgi.sock",
"bin-path" =>
"/export/home/webservd/trac/Trac-0.11dev/cgi-bin/trac.fcgi",
"check-local" => "disable",
"bin-environment" =>
("TRAC_ENV" => "/export/home/webservd/trac/trac",
"LC_TIME" => "de_CH",
"PYTHONPATH" =>
"/opt/csw/lib/python/site-packages")
)
)
)
}
auth.backend = "htpasswd"
$HTTP["url"] =~ "^/trac" {
auth.backend.htpasswd.userfile =
"/net/sys05/var/store/subversion/conf/svn-auth-file"
}
auth.require = ("/trac/login" =>
("method" => "basic",
"realm" => "Trac",
"require" => "valid-user"
)
)
############################################################ Trac!

I installed the Trac egg in the Python installation under
/opt/csw (ie. the binary is at /opt/csw/bin/python, site-packages
is at /opt/csw/lib/python/site-packages). Because of that,
I modified the 1st line of trac.fcgi to point to /opt/csw/bin/python
instead of /usr/bin/python.

I can startup lighttpd just fine with this configuration. BUT when
I try to access http://$SERVER/trac, I get this in the error log of
lighttpd:

2008-06-04 09:30:23: (log.c.75) server started
2008-06-04 09:30:28: (mod_fastcgi.c.1743) connect failed: Connection
refused on unix:/tmp/trac-fastcgi.sock-3
2008-06-04 09:30:28: (mod_fastcgi.c.2912) backend died; we'll disable
it for 5 seconds and send the request to another backend instead:
reconnects: 0 load: 1
2008-06-04 09:30:28: (mod_fastcgi.c.2432) unexpected end-of-file
(perhaps the fastcgi process died): 8
2008-06-04 09:30:28: (mod_fastcgi.c.3281) response not received,
request sent: 931 on socket: unix:/tmp/trac-fastcgi.sock-3 for /trac ,
closing connection

$ ls -la /tmp/trac-fastcgi.sock-*
srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-0
srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-1
srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-2
srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-3

Those files get created when I start lighttpd.

I can use Trac just fine when I use the standalone tracd,
which is in /opt/csw/bin.

What did I do wrong?

Thanks a lot,

Michael

Michael Schmarck

unread,
Jun 4, 2008, 4:21:33 AM6/4/08
to trac-...@googlegroups.com
Hello!

Michael Schmarck <michael.schmarck@...> writes:

> I can startup lighttpd just fine with this configuration. BUT when
> I try to access http://$SERVER/trac, I get this in the error log of
> lighttpd:
>
> 2008-06-04 09:30:23: (log.c.75) server started
> 2008-06-04 09:30:28: (mod_fastcgi.c.1743) connect failed: Connection
> refused on unix:/tmp/trac-fastcgi.sock-3
> 2008-06-04 09:30:28: (mod_fastcgi.c.2912) backend died; we'll disable
> it for 5 seconds and send the request to another backend instead:
> reconnects: 0 load: 1
> 2008-06-04 09:30:28: (mod_fastcgi.c.2432) unexpected end-of-file
> (perhaps the fastcgi process died): 8
> 2008-06-04 09:30:28: (mod_fastcgi.c.3281) response not received,
> request sent: 931 on socket: unix:/tmp/trac-fastcgi.sock-3 for /trac ,
> closing connection
>
> $ ls -la /tmp/trac-fastcgi.sock-*
> srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-0
> srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-1
> srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-2
> srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-3

As you can see/deduce here, I have lighttpd setup so, that it runs
as "webservd" user. To get everything to work, I needed to point
PYTHON_EGG_CACHE to some directory, were that user can write to.
So I changed my lighttpd.conf to read:

$HTTP["url"] =~ "^/trac(?!/chrome/common)" {
# Even if you have other fastcgi.server declarations for applications other than
Trac, do NOT use += here


fastcgi.server = ("/trac" =>
("trac" =>

("socket" => "/var/tmp/trac/fastcgi.sock",


"bin-path" =>
"/export/home/webservd/trac/Trac-0.11dev/cgi-bin/trac.fcgi",
"check-local" => "disable",
"bin-environment" =>
("TRAC_ENV" => "/export/home/webservd/trac/trac",
"LC_TIME" => "de_CH",

"PYTHONPATH" => "/opt/csw/lib/python/site-packages",
"PYTHON_EGG_CACHE" => "/var/tmp/trac")
)
)
)
}

Ie. I needed to add PYTHON_EGG_CACHE to the "bin-environment".

That's of course also covered in the Trac documentation at
http://trac.edgewall.org/wiki/TracFastCgi#SimpleLighttpdConfiguration :)

Out of interest: Where does lighttpd/python/trac/$whatever try to
write to, if PYTHON_EGG_CACHE is not set?

Thanks a lot,
Michael

dustin

unread,
Sep 11, 2008, 5:40:58 PM9/11/08
to Michael Schmarck, trac-...@googlegroups.com
I'm having a similar problem, but your solution mentioned here didn't
solve it (in fact, it didn't even change the error message).

I'm trying to get Trac installed using FastCGI for one vhost in my
overall Lighty system. I already have FastCGI handling all ".php"
requests on this server, and that is working wonderfully. I have about
10 vhosts, all working nicely, including the new one trying to serve
trac out of "trac.foo.com".

Here's my lighttpd conf:

327 $HTTP["host"] =~ "trac.foo.com" {
328 simple-vhost.server-root = "/srv/www/vhosts/"
329 simple-vhost.default-host = "trac.foo.com"
330 simple-vhost.document-root = "/htdocs/"
331 #auth.backend = "htdigest"
332 #auth.backend.htdigest.userfile = "/srv/www/vhosts/foo.com/
wiki/htdocs/lighttpd-htdigest.user"
333 #auth.require = ( "/" =>
334 # (
335 # "method" => "digest",
336 # "realm" => "Foo Wiki",
337 # "require" => "user=foo"
338 # ),
339 # )
340 fastcgi.debug = 1
341 fastcgi.server = ("/trac" =>
342 ("trac" =>
343 (
344 "check-local" => "disable",
345 "socket" => "/tmp/trac-fastcgi.sock",
346 "bin-path" => "/usr/lib/python2.3/site-packages/
Trac-0.11.1-py2.3.egg/trac/admin/templates/deploy_trac.fcgi",
347 "bin-environment" => (
348 "PYTHONPATH" => "/usr/lib/
python2.3/site-packages",
349 "PYTHON_EGG_CACHE" => "/var/
tmp/trac",
350 "TRAC_ENV" => "/srv/www/vhosts/
foo.com/trac/"
351 )
352 )
353 )
354 )
355 }

I suspect my problem is that when I installed Trac (
http://trac.edgewall.org/wiki/TracInstall ) it didn't seem to come
with the "trac.fcgi" that everyone references in their Lighttpd
setups. Where is that file? Am I expected to write it myself? I found
something that seems reasonable (see line 346 above), but it clearly
isn't working.

Any help is much appreciated!

On Jun 4, 1:21 am, Michael Schmarck


<michael.schma...@habmalnefrage.de> wrote:
> Hello!
>
>
>
> Michael Schmarck <michael.schmarck@...> writes:
> > I can startup lighttpd just fine with this configuration. BUT when
> > I try to access http://$SERVER/trac, I get this in the error log of
> > lighttpd:
>
> > 2008-06-04 09:30:23: (log.c.75) server started
> > 2008-06-04 09:30:28: (mod_fastcgi.c.1743) connect failed: Connection
> > refused on unix:/tmp/trac-fastcgi.sock-3
> > 2008-06-04 09:30:28: (mod_fastcgi.c.2912) backend died; we'll disable
> > it for 5 seconds and send the request to another backend instead:
> > reconnects: 0 load: 1
> > 2008-06-04 09:30:28: (mod_fastcgi.c.2432) unexpected end-of-file

> > (perhaps thefastcgiprocess died): 8


> > 2008-06-04 09:30:28: (mod_fastcgi.c.3281) response not received,
> > request sent: 931 on socket: unix:/tmp/trac-fastcgi.sock-3 for /trac,
> > closing connection
>
> > $ ls -la /tmp/trac-fastcgi.sock-*
> > srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-0
> > srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-1
> > srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-2
> > srwxr-xr-x 1 webservd nobody 0 Jun 4 09:30 /tmp/trac-fastcgi.sock-3
>
> As you can see/deduce here, I have lighttpd setup so, that it runs
> as "webservd" user. To get everything to work, I needed to point
> PYTHON_EGG_CACHE to some directory, were that user can write to.
> So I changed my lighttpd.conf to read:
>
> $HTTP["url"] =~ "^/trac(?!/chrome/common)" {

> # Even if you have otherfastcgi.server declarations for applications other thanTrac, do NOT use += here


> fastcgi.server = ("/trac" =>
> ("trac" =>
> ("socket" => "/var/tmp/trac/fastcgi.sock",
> "bin-path" =>
> "/export/home/webservd/trac/Trac-0.11dev/cgi-bin/trac.fcgi",
> "check-local" => "disable",
> "bin-environment" =>
> ("TRAC_ENV" => "/export/home/webservd/trac/trac",
> "LC_TIME" => "de_CH",
> "PYTHONPATH" => "/opt/csw/lib/python/site-packages",
> "PYTHON_EGG_CACHE" => "/var/tmp/trac")
> )
> )
> )
>
> }
>
> Ie. I needed to add PYTHON_EGG_CACHE to the "bin-environment".
>

> That's of course also covered in theTracdocumentation athttp://trac.edgewall.org/wiki/TracFastCgi#SimpleLighttpdConfiguration:)

Dustin S

unread,
Sep 18, 2008, 3:54:52 AM9/18/08
to Michael Schmarck, trac-...@googlegroups.com
I believe I figured this out myself: For some reason "trac.fcgi" is referenced in the Trac Wiki as the required FastCGI cgi-bin file, but not installed when you follow the method using "easy_install". I found the required file in the Trac source gz and it "just worked"!

Here's my final Lighttpd conf:

    290 $HTTP["host"] =~ "trac.foo.com" {
    291   simple-vhost.server-root   = "/srv/www/vhosts/"
    292   simple-vhost.default-host  = "trac.foo.com"
    293   simple-vhost.document-root = "/htdocs/"
    294   auth.backend               = "htpasswd"
    295   auth.backend.htpasswd.userfile = "/srv/www/vhosts/trac.foo.com/lighttpd-htpasswd.user"
    296   auth.require               = ( "/" =>
    297                                  (
    298                                    "method"  => "basic",
    299                                    "realm"   => "foouser",
    300                                    "require" => "user=foouser"
    301                                  ),
    302                                )
    303     fastcgi.debug = 1
    304     fastcgi.server = ("/" =>
    305       ("" =>
    306         (
    307           "check-local" => "disable",
    308           "socket" => "/tmp/trac-fastcgi.sock",
    310           "bin-path" => "/srv/www/vhosts/trac.foo.com/trac.fcgi",
    311           "bin-environment" => (
    314                                 "TRAC_ENV" => "/srv/www/vhosts/trac.foo.com/"
    315                                )
    316         )
    317       )
    318     )
    319 }

And here are the contents of trac.fcgi, which turns out to just be a python script:

#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2008 Edgewall Software
# Copyright (C) 2003-2004 Jonas Borgström <jo...@edgewall.com>
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://trac.edgewall.org/wiki/TracLicense.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://trac.edgewall.org/log/.
#
# Author: Jonas Borgström <jo...@edgewall.com>

try:
    from trac.web import fcgi_frontend
    fcgi_frontend.run()
except SystemExit:
    raise
except Exception, e:
    print 'Content-Type: text/plain\r\n\r\n',
    print 'Oops...'
    print
    print 'Trac detected an internal error:'
    print
    print e
    print
    import traceback
    import StringIO
    tb = StringIO.StringIO()
    traceback.print_exc(file=tb)
    print tb.getvalue()

Now my lighty install is happy and connecting to my server works, but Trac is giving me a new Subversion error I'm going to have to track down:

SubversionException: ("Expected FS format '2'; found format '3'", 160043)
Reply all
Reply to author
Forward
0 new messages