您的位置:首页 > 运维架构 > Nginx

安装nginx python uwsgi环境 以及模拟测试

2016-05-24 14:58 453 查看
uwsgi帮助文档:
http://uwsgi-docs-cn.readthedocs.io/zh_CN/latest/WSGIquickstart.html http://uwsgi-docs.readthedocs.io/en/latest/Async.html http://www.cnblogs.com/xiongpq/p/3381069.html
./configure: error: the HTTP rewrite module requires the PCRE library错误见下文
http://blog.csdn.net/hfsu0419/article/details/7190152
也可以参考廖雪峰的博客:
http://www.liaoxuefeng.com/article/001373892270040b645f6f886d94bdfbf57b8dd596f19b3000
uwsgi.ini中必须配置

py-autoreload = 1

否则程序修改不会生效,见文章:http://stackoverflow.com/questions/27813166/uwsgi-does-not-reload-after-changing-django-settings

手动命令启动uwsgi:

[root@crz_oa webserver]# uwsgi --http :9090 --wsgi-file home.py --daemonize /var/log/uwsgi.log

升级

[root@crz_oa webserver]# uwsgi --http :9090 --wsgi-file home.py --daemonize /var/log/uwsgi.log --master --harakiri 60 --socket-timeout 10

或者

[root@crz_oa webserver]# uwsgi -s 127.0.0.1:9090 --wsgi-file home.py --daemonize /var/log/uwsgi.log --master --harakiri 60 --socket-timeout 10

然后结合nginx通过socket接口调用

版本2 结合flask使用命令:

[root@crz_oa webserver]# uwsgi --http :9090 --wsgi-file home.py --daemonize /var/log/uwsgi.log --master --harakiri 60 --socket-timeout 10 -w home:app

参考http://docs.jinkan.org/docs/flask/deploying/uwsgi.html

如果出现错误:

uwsgi: option '--http' is ambiguous

换成这种写法

uwsgi --http-socket :9090 --wsgi-file home.py --daemonize /var/log/uwsgi.log --master --harakiri 60 --socket-timeout 10 -w home:app

囧,接着又出现错误:

uwsgi: unrecognized option '--wsgi-file'

sudo uwsgi --http-socket :9090 --plugin python --wsgi-file home.py --daemonize /var/log/uwsgi.log --master --harakiri 60 --socket-timeout 10 -w home:app

模拟测试可以去这个网站http://coolaf.com/,不仅可以模拟post提交,还可以添加各种cookie参数和header参数,以及各种代理:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: