python - Django - 主管 : exited too quickly

标签 python django nginx

我尝试在 Ubuntu 服务器 16.04 上使用 Django+Supervisor+NGINX 部署我的网站。

这是我的 .conf(主管):

[program:sitepro]
command = /home/user/sitepro/bin/gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002
user = user
autostart = true
autorestart = true

我的 NGINX 配置文件:

server {
    listen      80;
    server_name .mywebsite.fr;
    charset     utf-8;
    root /home/user/sitepro/site/sitepro;
    access_log /home/user/sitepro/site/logs/nginx/access.log;
    error_log /home/user/sitepro/site/logs/nginx/error.log;

    location /static {
        alias /home/user/sitepro/site/static;
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_redirect off;
        proxy_pass http://127.0.0.1:8002;
    }
}

当我尝试在项目的根目录下启动 gunicorn 时,一切正常:

(sitepro) user@mybps:~/sitepro/site$ gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002
[2017-11-01 16:09:37 +0000] [1920] [INFO] Starting gunicorn 19.7.1
[2017-11-01 16:09:37 +0000] [1920] [INFO] Listening at: http://79.137.39.12:8002 (1920)
[2017-11-01 16:09:37 +0000] [1920] [INFO] Using worker: sync
[2017-11-01 16:09:37 +0000] [1925] [INFO] Booting worker with pid: 1925

我已经完成了 supervisorctrl 重读和更新(有效)。 如果我让 supervisorctl status sitepro

sitepro                          FATAL     Exited too quickly (process log may have details)

如果我访问我的网站,我会看到“欢迎使用 Nginx”默认页面。

我已经尝试了很多部署 django 的教程:我迷路了,尝试了很多东西。 有人可以给我一个简单快速的教程来部署 Django 吗?

谢谢!

最佳答案

问题是您在配置文件中缺少 directory=...

[program:sitepro]
command = /home/user/sitepro/bin/gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002
directory = /home/user/sitepro/site
user = user
autostart = true
autorestart = true

否则gunicorn不知道去哪里找sitepro.wsgi:application

关于python - Django - 主管 : exited too quickly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47058301/

相关文章:

python - django-elasticsearch-dsl : how to search across multiple documents?

php - docker nginx php-fpm file_get_contents无法正常工作

ruby-on-rails-3 - Rails 应用程序占用所有服务器内存

linux - AWS/Ubuntu 存档服务器似乎已关闭?

python - 迭代多个全局列表和一个计数器 : for/while

python - Django 嵌套事务和异常

python - 自动文本摘要

python - 删除 kivy 图中的图

python - 如何访问 matplotlib 中的轴标签对象?

Django 模型 - 选择相关计数