环境

django == 1.11.16 nginx == 1.10.3

项目编写

安装nginx

配置uwsgi

  • 创建 xxx.ini 文件

    [uwsgi]socket=:9000     # 端口chdir=/mnt/project/project_api   # 项目路径 包含manage.py的路径module=pro.wsgi   #pro为包含wsgi.py文件的文件名master=trueprocesses=4vacuum=true

配置nginx

  • vim  /etc/nginx/nginx.conf
  • nginx.conf文件http{}中添加一个server

    server {    listen       80;    server_name  域名 或者 localhost;     charset UTF-8;    access_log  /var/log/nginx/djangohost.access.log;    error_log  /var/log/nginx/djangohost.error.log;    location / {        include uwsgi_params;        uwsgi_pass 127.0.0.1:9000;        uwsgi_read_timeout 2;     }    error_page   500 502 503 504  /50x.html;    location = /50x.html {        root   html;    }}
  • 重启nginx

    ps -ef | grep nginxkill -HUP  < pid ># 或者使用 serviceservice nginx restart

    启动项目

收藏 打印