forked from webpy/webpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added deploying using lighttpd + fastcgi
- Loading branch information
1 parent
315abc2
commit 5833528
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
Deploying web.py applications | ||
============================= | ||
|
||
FastCGI | ||
------- | ||
|
||
web.py uses `flup`_ library for supporting fastcgi. Make sure it is installed. | ||
|
||
.. _flup: http://trac.saddi.com/flup | ||
|
||
You just need to make sure you applicaiton file is executable. Make it so by adding the following line to tell the system to execute it using python:: | ||
|
||
#! /usr/bin/env python | ||
|
||
and setting the exeutable flag on the file:: | ||
|
||
chmod +x /path/to/yourapp.py | ||
|
||
Configuring lighttpd | ||
^^^^^^^^^^^^^^^^^^^^ | ||
|
||
Here is a sample lighttpd configuration file to expose a web.py app using fastcgi. :: | ||
|
||
# Enable mod_fastcgi and mod_rewrite modules | ||
server.modules += ( "mod_fastcgi" ) | ||
server.modules += ( "mod_rewrite" ) | ||
|
||
# configure the application | ||
fastcgi.server = ( "/yourapp.py" => | ||
(( | ||
# path to the socket file | ||
"socket" => "/tmp/yourapp-fastcgi.socket", | ||
|
||
# path to the application | ||
"bin-path" => "/path/to/yourapp.py", | ||
|
||
"max-procs" => 1, | ||
"bin-environment" => ( | ||
"REAL_SCRIPT_NAME" => "" | ||
), | ||
"check-local" => "disable" | ||
)) | ||
) | ||
|
||
url.rewrite-once = ( | ||
# favicon is usually placed in static/ | ||
"^/favicon.ico$" => "/static/favicon.ico", | ||
|
||
# Let lighttpd serve resources from /static/. | ||
# The web.py dev server automatically servers /static/, but this is | ||
# required when deploying in production. | ||
"^/static/(.*)$" => "/static/$1", | ||
|
||
# everything else should go to the application, which is already configured above. | ||
"^/(.*)$" => "/yourapp.py/$1", | ||
) | ||
|
||
With this configuration lighttpd takes care of starting the application. The webserver tasks to your application using fastcgi via a unix domain socket. This means both the webserver and the application will run on the same machine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ Contents: | |
input | ||
db | ||
templating | ||
deploying | ||
api | ||
|
||
Getting Started | ||
|