Nginx+uWSGI部署Django

配置运行环境

pip install uwsgi
pip install django

配置uWSGI

vim uwsgi.ini
[uwsgi] 
socket = 127.0.0.1:8001
chdir = /www/wwwroot/django.pw
module = bookMan.wsgi:application 
env = DJANGO_SETTINGS_MODULE = bookMan.settings 
master = true 
processes = 4
vacuum = true 
uwsgi --ini uwsgi.ini #查看uwsgi的启动信息,若无报错,直接静默启动 -d
echo 'uwsgi -d --ini uwsgi.ini ' >> /etc/rc.local

配置Nginx

location / { 
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:8001;
    }   
location /static {
        alias /www/wwwroot/django.pw/static;
    }

配置Django

ALLOWED_HOSTS = ['django.pw']
STATIC_ROOT = '/www/wwwroot/django.pw/static/' #在Setting添加
python manage.py collectstatic

发表评论