我正在尝试部署一个使用Python和Flask构建的简单Web应用程序.
我的应用程序具有以下结构:
/var/www/watchgallery/
+ app
+ __init__.py
+ views.py
+ templates
+ flask #virtual environment for Flask
+ run.py #script I used in my machine to start the development Flask server
+ watchgallery_Nginx.conf
+ watchgallery_uwsgi.ini
+ watchgallery_uwsgi.sock
为此,我遵循以下链接:http://vladikk.com/2013/09/12/serving-flask-with-nginx-on-ubuntu/
在本教程中,Flask应用程序仅包含hello.py文件.他配置uwsgi文件的方式如下所示(/var/www/demoapp/demoapp_uwsgi.ini):
[uwsgi]
#application's base folder
base = /var/www/demoapp
#python module to import
app = hello
module = %(app)
home = %(base)/venv
pythonpath = %(base)
#socket file's location
socket = /var/www/demoapp/%n.sock
#permissions for the socket file
chmod-socket = 666
#the variable that holds a flask application inside the module imported at line #6
callable = app
#location of log files
logto = /var/log/uwsgi/%n.log
我试图将相同的逻辑应用于uwsgi.ini文件,但是我做错了.这是我的文件的样子:
[uwsgi]
#application's base folder
base = /var/www/watchgallery
#python module to import
app = run
module = %(app)
home = %(base)/flask
pythonpath = %(base)
#socket file's location
socket = /var/www/watchgallery/%n.sock
#permissions for the socket file
chmod-socket = 666
#the variable that holds a flask application inside the module imported at line #6
callable = app
当我在本地计算机上开发应用程序时,我运行以下命令来启动服务器:./run.py.
这是我的run.py文件:
#!flask/bin/python
from app import app
app.run(debug = False)
最佳答案
原文链接:https://www.f2er.com/nginx/532419.html