supervisor 和gunicorn部署django项目

安装使用到的基本软件nginx、supervisor、gunicorn

vi /etc/supervisor/conf.d/django_project.conf

[program:django_project]
command=gunicorn xxx.wsgi:application -b 127.0.0.1:8080 -w 8
user=user #当前用户
directory=/home/user/django_project
stdout_logfile=/tmp/var/logs/supervisor/%(program_name)s-stdout.log
stderr_logfile=/tmp/var/logs/supervisor/%(program_name)s-stderr.log
killasgroup=true
stopasgroup=true
autorstart=true
autorestart=true

# rq队列的配置

[program:rqworker]
command=python manage.py rqworker default low
user=user
directory=/home/django_project/platform
stdout_logfile=/tmp/var/logs/supervisor/%(program_name)s-stdout.log
stderr_logfile=/tmp/var/logs/supervisor/%(program_name)s-stderr.log
killasgroup=true
stopasgroup=true
autorstart=true
autorestart=true```

再在nginx配置中的location,添加

proxy_pass http://127.0.0.1:8080;

另外静态文件的代理可以添加下面的配置

location /static/ {

alias /django_project/statics/;

}

    原文作者:1只鱼
    原文地址: https://segmentfault.com/a/1190000012856428
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞