Skip to content

Commit 94f90bc

Browse files
fmwmitsuhiko
authored andcommitted
updated docs on FastCGI deployment with Lighty
Signed-off-by: Armin Ronacher <[email protected]>
1 parent 4228d72 commit 94f90bc

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

docs/deploying/fastcgi.rst

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ First you need to create the FastCGI server file. Let's call it
2525
#!/usr/bin/python
2626
from flup.server.fcgi import WSGIServer
2727
from yourapplication import app
28+
29+
if __name__ == '__main__':
30+
WSGIServer(app).run()
2831

29-
WSGIServer(app).run()
30-
31-
This is enough for Apache to work, however lighttpd and nginx need a
32-
socket to communicate with the FastCGI server. For that to work you
33-
need to pass the path to the socket to the
32+
This is enough for Apache to work, however nginx and older versions of
33+
lighttpd need a socket to be explicitly passed to communicate with the FastCGI
34+
server. For that to work you need to pass the path to the socket to the
3435
:class:`~flup.server.fcgi.WSGIServer`::
3536

3637
WSGIServer(application, bindAddress='/path/to/fcgi.sock').run()
@@ -54,21 +55,33 @@ Configuring lighttpd
5455

5556
A basic FastCGI configuration for lighttpd looks like that::
5657

57-
fastcgi.server = ("/yourapplication" =>
58-
"yourapplication" => (
58+
fastcgi.server = ("/yourapplication.fcgi" =>
59+
((
5960
"socket" => "/tmp/yourapplication-fcgi.sock",
6061
"bin-path" => "/var/www/yourapplication/yourapplication.fcgi",
61-
"check-local" => "disable"
62-
)
62+
"check-local" => "disable",
63+
"max-procs" -> 1
64+
))
65+
)
66+
67+
alias.url = (
68+
"/static/" => "/path/to/your/static"
6369
)
6470

65-
This configuration binds the application to `/yourapplication`. If you
66-
want the application to work in the URL root you have to work around a
67-
lighttpd bug with the :class:`~werkzeug.contrib.fixers.LighttpdCGIRootFix`
68-
middleware.
71+
url.rewrite-once = (
72+
"^(/static.*)$" => "$1",
73+
"^(/.*)$" => "/yourapplication.fcgi$1"
74+
75+
Remember to enable the FastCGI, alias and rewrite modules. This configuration
76+
binds the application to `/yourapplication`. If you want the application to
77+
work in the URL root you have to work around a lighttpd bug with the
78+
:class:`~werkzeug.contrib.fixers.LighttpdCGIRootFix` middleware.
6979

7080
Make sure to apply it only if you are mounting the application the URL
71-
root.
81+
root. Also, see the Lighty docs for more information on `FastCGI and Python
82+
<http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModFastCGI>`_ (note that
83+
explicitly passing a socket to run() is no longer necessary).
84+
7285

7386
Configuring nginx
7487
-----------------

0 commit comments

Comments
 (0)