django官方文档在这
https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/uwsgi/
第一步:先收集静态文件
之前要先设置
STATIC_ROOT = os.path.join(BASE_DIR,'static')
然后执行命令
python manage.py collectstatic
第二步:配置nginx
server { server_name qq.com; location /static{ #location 与STATIC_URL一致 #alias 与STATIC_ROOT一致 alias /var/www/qq.com/static; } location / { #与之后uwsgi配置一致 proxy_pass http://127.0.0.1:8000/; } }
第三步:配置uwsgi.ini
[uwsgi]
chdir=/var/www/qq.com
uid=www-data
gid=www-data
module={{projectname}}.wsgi:application
socket=127.0.0.1:8000
protocol=http
master=true
workers=5
pidfile=/var/www/qq.com/uwsgi.pid
vacuum=true
thunder-lock=true
enable-threads=true
harakiri=30
post-buffering=4096
daemonize=/var/www/qq.com/uwsgi.log
{{projectname}}替换成自己的project名字
之后就好了
启动uwsgi --ini uwsgi.ini
关闭uwsgi --stop uwsgi.pid