初次使用uwsgi:no python application found, check your startup logs for errors

按照文档,首先写一个test.py的文件,进行测试是否安装成功

1 def application(env, start_response):
2     start_response('200 OK', [('Content-Type','text/html')])
3     return ["Hello World"]

 

结果刚开始既不显示内容,也不现实错误

仔细查看运行回显:出现了一段 没有使用 pcre,于是重新安装 uwsgi

首先执行

sudo pip uninstall uwsgi

出现了 没有目录权限的提示

执行, sudo chown -R $(whoami) /***/http

然后重新执行, sudo pip uninstall uwsgi

卸载完成

重新安装,这次没有采用pip install uwsgi

而是,直接在https://pypi.python.org/pypi/uWSGI/ 进行下载tar包

执行

tar -xvf uwsgi-2.0.15.tar.gz

cd uwsgi-2.0.15

make

重新执行,结果一直显示 no python application found, check your startup logs for errors

查看手册,发现python3,需要使用下面的代码

1 def application(env, start_response):
2     start_response('200 OK', [('Content-Type','text/html')])
3     return [b"Hello World"]

可是仍旧不行

重新查看手册,发现,需要在命令行添加参数 --plugin python

执行下面命令行: 

uwsgi --plugin python --http :8001 --wsgi-file test.py

重新访问 localhost:8001

就可以看到 成功的显示了 'Hello world'

 

PS:附件为uwsgi的手册

https://media.readthedocs.org/pdf/uwsgi-docs-additions/latest/uwsgi-docs-additions.pdf

 

posted @ 2017-12-26 19:48  begeeeeeeek  阅读(14279)  评论(0编辑  收藏  举报