supervisor 和gunicorn部署django项目

SenZendao 2019-06-26

安装使用到的基本软件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/;

}

相关推荐

yyyxxxs / 0评论 2020-05-10