猫/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;
}
猫/etc/uwsgi/apps-available/website.ini
[uwsgi]
plugins=python
vhost=true
socket=/tmp/website.sock
猫/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应用程序”。
最佳答案
我在相同的配置中有相同的错误,而我的问题仅仅是uwsgi服务未启动。重新启动nginx和uwsgi均解决了该问题。
关于python - flask + nginx + uwsgi-找不到Python应用程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14278424/