参考的文档是
http://blog.163.com/sky20081816@126/blog/static/1647610232010824262695/
但在实操时,作了更改之后才生效,就是#include fcgi.conf;include fastcgi_params;这里。
server{
listen 8000;
server_name localhost;
location / {
fastcgi_pass 127.0.0.1:8008;
fastcgi_param SCRIPT_FILENAME “”;
fastcgi_param PATH_INFO $fastcgi_script_name;
#include fcgi.conf;
include fastcgi_params;
}
}
~~~~~~~~~~~
然后我们再写一个fcgi.py,代码如下#!/usr/bin/python# encoding : utf-8 from flup.server.fcgi import WSGIServer def myapp(environ, start_response): start_response(‘200 OK’, [(‘Content-Type’, ‘text/plain’)]) return [‘Hello World!\n’] if __name__ == ‘__main__’: WSGIServer(myapp,bindAddress=(‘127.0.0.1’,8008)).run()(注2) 注2,看到了吗,这里的bindAddress 的值是一个元组,这个是WSGIServer的源代码要求这么写的,而且它的值对应的是上面fastcgi-pass的值 然后我们就可以运行python fcgi.py –method=prefork/threaded minspare=50 maxspare=50 maxchildren=1000 (注3)注3:后面的那些参数相当于php-cgi后面的参数,但是具体的用途还需要进一步探索 运行到这了,我们就可以在浏览器里面敲: http://localhost:8000如果返回 Hello World,恭喜你,迈出了nginx 运行python的第一步