Fastcgi on lighttpd

Version 8 (Peter Mortensen, 04/15/2011 10:52 pm)

1 7 Peter Mortensen
h1. FastCGI on lighttpd
2 1
3 1
{{toc}}
4 1
5 1
6 8 Peter Mortensen
h3. openSUSE configuration
7 1
8 8 Peter Mortensen
* On openSUSE the lighttpd is in the factory tree at repos.opensuse.org
9 2 Pieter Libin
  http://repos.opensuse.org:/http/SUSE_Linux_10.1/i586/lighttpd-1.4.15-6.1.i586.rpm
10 1
* Store the wt application in /srv/www/cgi-bin
11 2 Pieter Libin
 /srv/www/cgi-bin/helloworld.fcgi
12 8 Peter Mortensen
* The openSUSE lighttpd configuration are modular - create a new file /etc/lighttpd/conf.d/helloworld.conf
13 3 Pieter Libin
 <pre>
14 2 Pieter Libin
fastcgi.server += ("/helloworld" =>
15 1
                   ("helloworld" =>
16 1
                     ("socket" => "/usr/wt/socket",
17 1
                      "bin-path" => "/srv/www/cgi-bin/helloworld.fcgi",
18 1
                      "max-procs" => 1,
19 1
                      "check-local" => "disable",
20 1
                      "bin-environment" => ("FOO" => "bar")
21 1
                     )
22 1
                    )
23 1
                )
24 3 Pieter Libin
 </pre>
25 1
* in /etc/lighttpd/modules.conf
26 2 Pieter Libin
 enable the following (existing) section
27 3 Pieter Libin
 <pre>
28 1
##
29 1
## FastCGI (mod_fastcgi)
30 1
##
31 1
include "conf.d/fastcgi.conf"
32 3 Pieter Libin
 </pre>
33 4 Pieter Libin
 append an include line at the end of the modules.conf file
34 3 Pieter Libin
 <pre>
35 1
include "conf.d/helloworld.conf"
36 3 Pieter Libin
 </pre>
37 1
38 1
* When done you can access the application on htpp://your.server/helloworld
39 1
40 7 Peter Mortensen
h3. Flat File Configuration 
41 1
42 7 Peter Mortensen
If you have a single configuration file, add such a section
43 3 Pieter Libin
 <pre>
44 1
server.modules += ( "mod_fastcgi" )
45 1
fastcgi.server += ("/helloworld" =>
46 1
                   ("helloworld" =>
47 1
                     ("socket" => "/usr/wt/socket",
48 1
                      "bin-path" => "/srv/www/cgi-bin/helloworld.fcgi",
49 1
                      "max-procs" => 1,
50 1
                      "check-local" => "disable",
51 1
                      "bin-environment" => ("FOO" => "bar")
52 1
                     )
53 1
                    )
54 1
                )
55 3 Pieter Libin
 </pre>
56 1
* When done you can access the application on htpp://your.server/helloworld
57 1
58 1
59 1
h3. /usr/wt 
60 1
61 7 Peter Mortensen
The FastCGI socket has been put into /usr/wt/socket because the default Wt build does put its own session server sockets as $prefix/wt/run/server-$X. There is no requirement to let the lighttpd precreate FastCGI Wt servers to handle different connections as Wt will schedule server creation and session scheduling internally. The internal creation of session servers is not logged to httpd log (where it should be).