flask + nginx + uwsgi - 找不到Python应用程序

时间:2013-01-11 12:40:42

标签: python nginx flask uwsgi

cat / etc / nginx / sites-available / mywebsite

server {
     listen              80;

    server_name         mywebsite;

    location /static {
        alias           /var/www/mywebsite/static;
    }

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/tmp/website.sock;
        uwsgi_param         UWSGI_PYHOME    /var/www/mywebsite/env;
        uwsgi_param         UWSGI_CHDIR     /var/www/mywebsite;
        uwsgi_param         UWSGI_MODULE    mywebsite;
        uwsgi_param         UWSGI_CALLABLE  mywebsite;
    }

    error_page          404     /404.html;

}

cat /etc/uwsgi/apps-available/website.ini

[uwsgi]
plugins=python
vhost=true
socket=/tmp/website.sock

cat /var/www/mywebsite/mywebsite.py

from flask import Flask
app = Flask(__name__)

@app.route("/")
def index():
    return "It works!"

if __name__ == "__main__":
    app.run()

我正在运行nginx,然后是uwsgi,并且在浏览器中找不到uWSGI错误'Python应用程序'。

2 个答案:

答案 0 :(得分:2)

我有相同的错误,在相同的配置中,我的问题只是uwsgi服务没有启动。重新启动nginx和uwsgi解决了这个问题。

答案 1 :(得分:1)

UWSGI_CALLABLE必须是'app'(是在请求中调用的函数的名称)