试图用nginx和gunicorn设置烧瓶
我遵循了一个简单的指南,并试图显示我的烧瓶应用程序,但它不会显示。我正在通过Ubuntu服务器上的SSH运行所有内容。
使用我的flask app和wsgi.py。
在/var/www/application/我的nginx配置
server {
listen 80;
server_name application;
access_log /var/log/nginx/application.access.log;
error_log /var/log/nginx/appliation.error.log;
location / {
include proxy_params;
proxy_pass http://unix:/var/www/application/application.sock;
}
}
请
中, 位于:/etc/systemd/system/application.service中
[Unit]
Description=application.service - A Flask application run with Gunicorn.
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/var/www/application/
ExecStart=/usr/bin/gunicorn --workers 3 --bind unix:/var/www/application.sock wsgi:app
[Install]
WantedBy=multi-user.target
已检查所有进程正在运行,SystemD状态可以正常运行,但是当我尝试卷发时,
http://application
我什么都没有得到?
我的app.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def home():
return "<h1>Nginx & Gunicorn</h1>"
wsgi.py
from main import app
if __name__ == "__main__":
app.run(debug=True)
我在这里缺少什么,如何使它起作用?
I have followed a simple guide, and trying to show my flask application, but it wont show. I am running everything through ssh on a ubuntu server.
Have my flask app and wsgi.py in /var/www/application/
My nginx config is:
server {
listen 80;
server_name application;
access_log /var/log/nginx/application.access.log;
error_log /var/log/nginx/appliation.error.log;
location / {
include proxy_params;
proxy_pass http://unix:/var/www/application/application.sock;
}
}
I have symlinked the file to /etc/nginx/sites-enabled/
Then here is my gunicorn application config
located in: /etc/systemd/system/application.service
[Unit]
Description=application.service - A Flask application run with Gunicorn.
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/var/www/application/
ExecStart=/usr/bin/gunicorn --workers 3 --bind unix:/var/www/application.sock wsgi:app
[Install]
WantedBy=multi-user.target
Have checked all processes are running, and systemd status ok, but when i try to curl
http://application
I get nothing?
My app.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def home():
return "<h1>Nginx & Gunicorn</h1>"
wsgi.py
from main import app
if __name__ == "__main__":
app.run(debug=True)
What am I missing here, how to get it working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是路径/var/www/application.sock ,应该是:/var/www/application/application.sock
您仍然可以查看使用命令服务:
sudo systemctl status&lt; service_name&gt;
了解服务文件中指定的命令是否正确,或者如果应用程序启动问题,请尝试直接从命令行启动:
the problem is the path /var/www/application.sock, it should be: /var/www/application/application.sock
You can still view the status of the service with the command:
sudo systemctl status <service_name>
To understand if the command specified in the service file is correct, or if the application has problems starting, try to start it directly from the command line: