如何配置蟒蛇+ uwsgi + nginx的?(How to configure python+uw

2019-08-17 06:50发布

我试图运行与uwsgi + nginx的python脚本。 这导致在浏览器这个错误:

uWSGI Error
Python application not found

var/log/uwsgi/app/pyec.loc.log字符串是:

Sun Mar  3 01:34:36 2013 - added /home/lunochkinma/py_projects/pyec/ to pythonpath.
Sun Mar  3 01:34:36 2013 - mounting hello on /home/lunochkinma/py_projects/pyec/
Sun Mar  3 01:34:36 2013 - *** no app loaded. going in full dynamic mode ***
Sun Mar  3 01:34:36 2013 - *** uWSGI is running in multiple interpreter mode ***

我uwsgi应用程序配置:

<uwsgi>
        <plugin>python</plugin>
        <socket>/run/uwsgi/app/pyec.loc/pyec.loc.socket</socket>
        <pythonpath>/home/lunochkinma/py_projects/pyec</pythonpath>
        <app mountpoint="/">
                <script>hello</script>
        </app>
        <master/>
        <processes>4</processes>
        <harakiri>60</harakiri>
        <reload-mercy>8</reload-mercy>
        <cpu-affinity>1</cpu-affinity>
        <stats>/tmp/stats.socket</stats>
        <max-requests>2000</max-requests>
        <limit-as>512</limit-as>
        <reload-on-as>256</reload-on-as>
        <reload-on-rss>192</reload-on-rss>
        <no-orphans/>
        <vacuum/>
</uwsgi>

Python的WSGI文件:

# /home/lunochkinma/py_projects/pyec/hello.py

def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return b'Hello World!'

Nginx的配置:

server {
        listen 80;
        server_name paec.loc;
        access_log /var/log/nginx/pyec.loc.access.log;
        error_log /var/log/nginx/pyec.loc.error.log;
        location / {
                uwsgi_pass unix:///run/uwsgi/app/pyec.loc/pyec.loc.socket;
                include uwsgi_params;
                uwsgi_param UWSGI_SCHEME $scheme;
                uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
        }
        location /static {
                root /home/lunochkinma/py_projects/pyec/static/;
                index index.html index.htm;
        }
}

软:Ubuntu的12.04,nginx的1.2.1,1.4.8 uwsgi,蟒蛇3.2.3

Answer 1:

(回答一个问题的编辑,转换为一个社区维基回答,见什么是当一个问题的答案被添加到问题本身相应的操作? )

该OP写道:

问题是通过向uwsgi应用程序配置参数“模块”来解决:

 <uwsgi> <plugin>python</plugin> <socket>/run/uwsgi/app/pyec.loc/pyec.loc.socket</socket> <pythonpath>/home/lunochkinma/py_projects/pyec</pythonpath> <app mountpoint="/"> <script>hello</script> </app> <module>hello</module> <master/> <processes>4</processes> <harakiri>60</harakiri> <reload-mercy>8</reload-mercy> <cpu-affinity>1</cpu-affinity> <stats>/tmp/stats.socket</stats> <max-requests>2000</max-requests> <limit-as>512</limit-as> <reload-on-as>256</reload-on-as> <reload-on-rss>192</reload-on-rss> <no-orphans/> <vacuum/> </uwsgi> 


文章来源: How to configure python+uwsgi+nginx?