【发布时间】:2018-08-21 20:53:07
【问题描述】:
这就是我的配置的样子
#/etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=django
Group=www-data
WorkingDirectory=/home/django/testapp
ExecStart=/home/django/venvs/testenv/bin/gunicorn --workers 3 --bind unix:/home/django/testapp/testapp.sock testapp.wsgi:application
[Install]
WantedBy=multi-user.target
这是我的 nginx 配置:
# /etc/nginx/sites-enabled/testapp
server {
listen 80;
server_name server_domain_or_IP;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/django/static;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/django/testapp/testapp.sock;
}
}
我注意到,如果我从控制台运行此命令:
/home/django/venvs/testenv/bin/gunicorn --workers 3 --bind unix:/home/django/testapp/testapp.sock testapp.wsgi:application
然后它显示就像它在控制台中工作一样,但 URL 仍然无法访问。
这是输出的样子:
[2016-07-11 16:29:41 -0400] [1545] [INFO] Starting gunicorn 19.6.0
[2016-07-11 16:29:41 -0400] [1545] [INFO] Listening at: unix:/home/django/testapp/testapp.sock (1545)
[2016-07-11 16:29:41 -0400] [1545] [INFO] Using worker: sync
[2016-07-11 16:29:41 -0400] [1548] [INFO] Booting worker with pid: 1548
[2016-07-11 16:29:41 -0400] [1550] [INFO] Booting worker with pid: 1550
[2016-07-11 16:29:41 -0400] [1551] [INFO] Booting worker with pid: 1551
但是,我仍然无法访问服务器的 url。我尝试使用端口 80、8000 和 9001 打开 url,但都没有工作。 (nginx 在 80 上运行)。
我正在使用 python3.5 和 gunicorn 19.6.0。
有人有什么建议吗?非常感谢!
【问题讨论】:
-
你能解决这个问题@bla0009 吗?我在烧瓶中遇到类似的问题?在这里发布stackoverflow.com/q/43754151/3834059
标签: python-3.x nginx gunicorn