@@ -25,12 +25,13 @@ First you need to create the FastCGI server file. Let's call it
25
25
#!/usr/bin/python
26
26
from flup.server.fcgi import WSGIServer
27
27
from yourapplication import app
28
+
29
+ if __name__ == '__main__':
30
+ WSGIServer(app).run()
28
31
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
34
35
:class: `~flup.server.fcgi.WSGIServer `::
35
36
36
37
WSGIServer(application, bindAddress='/path/to/fcgi.sock').run()
@@ -54,21 +55,33 @@ Configuring lighttpd
54
55
55
56
A basic FastCGI configuration for lighttpd looks like that::
56
57
57
- fastcgi.server = ("/yourapplication" =>
58
- "yourapplication" => (
58
+ fastcgi.server = ("/yourapplication.fcgi " =>
59
+ ( (
59
60
"socket" => "/tmp/yourapplication-fcgi.sock",
60
61
"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"
63
69
)
64
70
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.
69
79
70
80
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
+
72
85
73
86
Configuring nginx
74
87
-----------------
0 commit comments