nginx配置
在/usr/local/nginx/conf/nginx.conf文件中添加如下:
location = / {
fastcgi_pass 127.0.0.1:8088;
fastcgi_param SCRIPT_FILENAME fcgi$fastcgi_script_name;
include fastcgi.conf;
}
重启nginx
测试代码:文件名:main.py
import sys
import traceback
import Ice
import json
from flup.server.fcgi import WSGIServer
#Http请求处理和回复
def HttpReqHandler(environ, start_response):
try:
status = '200 OK'
response_headers = [('Content-Type', 'text/json')]
start_response(status, response_headers)
return ["hello world"]
if __name__ == '__main__':
WSGIServer(HttpReqHandler, bindAddress=('127.0.0.1',8088)).run()
启动pythonfcgi模块
python main.py --method=prefork/threaded minspare=10 maxspare=20 maxchildren=50
浏览器请求URL:http://192.168.100.195:8080
可看到打印:hello world