nginx+uwsgi,django项目的部署

最近在linux上部署django项目走了不少弯路,在另一位博主那找到了配置方法,也参照了uwsgi的官方文档,终于是配置成功了,记录一下方便以后配置
前提条件:
1.你的django程序能够跑通
2.你的nginx和uwsgi都没问题
ps:django版本:2.1.3
项目路径:
/home/projects/curriculum
项目结构

  • curriculum
    • curriculum
      • __init__.py
      • settings.py
      • urls.py
      • wsgi.py
    • manage.py
    • db.sqlite3

uwsgi配置

[uwsgi]
http = 127.0.0.1:8080
chdir = /home/projects/curriculum/
module = curriculum.wsgi
socket = /home/projects/curriculum/uwsgi.sock  # 配置好会自动创建文件的,不用纠结于没有这个文件
master = true
processes = 4
threads = 2
enable-threads = True
buffer-size = 21573
vacuum = true
uid = root
gid = root
# static-map = /home/projects/curriculum/static
# 可以配置static目录
daemonize = /tmp/uwsgi.log

nginx配置

server {
    listen       80;
    server_name  localhost;
    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
        include /etc/nginx/uwsgi_params;  #最关键的两步
        uwsgi_pass unix:/home/projects/curriculum/uwsgi.sock;  #最关键的两步
    }
}

这里其实还差upstream没有配置,可以根据uwsgi的文档配置一下
配置文件写好后执行命令:

nginx -s reload
uwsgi --ini /etc/uwsgi.ini

最后访问你服务器的地址,就能django的开始界面了

你可能感兴趣的:(Linux,django)