Browse files


  • Loading branch information...
1 parent 10a4685 commit 38ddde08169b66d0021bc91f821e7e3d9755900b guojing committed with anandology Jul 24, 2010
Showing with 31 additions and 29 deletions.
  1. +31 −29 cookbook/
@@ -1,35 +1,36 @@
layout: default
-title: Webpy + Nginx with FastCGI
+title: Webpy + Nginx with FastCGI搭建
-# Webpy + Nginx with FastCGI
+# Webpy + Nginx with FastCGI搭建
-This cookbook entry explains how to run on Nginx with Fastcgi.
-### Requirements
+### 环境依赖的软件包
-* Nginx 0.8.\* or 0.7.\* (with fastcgi and rewrite module).
+* Nginx 0.8.\* or 0.7.\* (需要包含fastcgi和rewrite模块)。
* Webpy 0.32
* Spawn-fcgi 1.6.2
* Flup
-Older versions may work, but aren't tested.
-### Resources
+### 一些资源
* [Nginx wiki](
* [Spawn-fcgi](
* [Flup](
### Notes
-* You may replace `` with your own file name.
-* `/path/to/www` Is the path to the directory where your webpy application is located.
-* `/path/to/www/` is the full path to your python file.
-* Do not run anything until you are at *Run*.
+* 你可以重命名``为任何你想要的文件名。
+* `/path/to/www` 为代码路径。
+* `/path/to/www/`为python代码的完整路径。
-## Nginx configuration
+## Nginx 配置文件
location / {
include fastcgi_params;
@@ -38,40 +39,39 @@ Older versions may work, but aren't tested.
-To serve static files add this:
location /static/ {
if (-f $request_filename) {
rewrite ^/static/(.*)$ /static/$1 break;
-__Note:__ the address and port may be different.
+__注意:__ 地址和端口号可能会是不同的。
## Spawn-fcgi
-You can start a process with:
spawn-fcgi -d /path/to/www -f /path/to/www/ -a -p 9002
-### Start and shutdown script
+### 启动和关闭的命令
spawn-fcgi -d /path/to/www -f /path/to/www/ -a -p 9002
kill `pgrep -f "python /path/to/www/"`
-__Note:__ You're free to choose which address, port, directory and filename to use, but be sure to adjust the Nginx configuration.
+__Note:__ 你可以随意填写地址和端口信息,但是一定需要和Nginx配置文件相匹配。
## Hello world!
-Save the following code in your www directory and call the file (or whatever you like).
-The following line is required: `web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)`.
+讲下面的代码保存为或者任何你喜欢的),注意,使用Nginx配置的话,`web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)`这一行代码是必须的。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
@@ -89,19 +89,21 @@ The following line is required: `web.wsgi.runwsgi = lambda func, addr=None: web.
web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)
-Note: make your file executable by doing `chmod +x`. You'll get errors if it isn't executable.
+注意: 同样需要给代码设置权限,代码如下chmod +x
-## Run
+## 运行
-1. Start a process with `spawn-fcgi`.
-2. Start Nginx.
+1. 打开一个 `spawn-fcgi` 进程.
+2. 打开 Nginx.
-To check if it runs do `ps aux | grep` or simply visit the page in your browser.
+如果需要检查应用程序是否运行,使用`ps aux|grep`可以很容易的查看。
-To reload your configuration:
/path/to/nginx/sbin/nginx -s reload
-And to stop:
+ /path/to/nginx/sbin/nginx -s stop
- /path/to/nginx/sbin/nginx -s stop

0 comments on commit 38ddde0

Please sign in to comment.