Python 官方文档:入门教程 => 点击学习
windows下Nginx配置python服务器 安装Python 安装flup包 创建Python server 配置nginxconf 启动nginx 测试 参考文献 Http://blog.163.com/s
参考文献 Http://blog.163.com/sky20081816@126/blog/static/1647610232010824262695/
运行WinPython-64bit-2.7.9.2.exe
并手动设置PATH环境变量
下载 http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gz
解压
在解压目录中运行
python setup.py install
成功提示
Installed f:/python25/lib/site-packages/flup-1.0.2-py2.5.egg
Processing dependencies for flup==1.0.2
Finished processing dependencies for flup==1.0.2
创建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()
在命令行中运行
python fcgi.py --method=prefork/threaded minspare=50 maxspare=50 maxchildren=1000
这个server即在8080端口监听http请求,若有请求则返回“hello world”
http {
server{
listen 8000; #nginx服务端口
server_name test.com;
location /{
fastcgi_pass 127.0.0.1:8008; #python server的端口
fastcgi_param SCRIPT_FILENAME "";
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi.conf;
}
}
}
nginx.exe
打开浏览器,输入localhost:8000
会看到hello world
--结束END--
本文标题: Windows下nginx配置pytho
本文链接: https://www.lsjlt.com/news/189536.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0