zoukankan      html  css  js  c++  java
  • 最简单的uwsgi+nginx配置多个django站点

    1. nginx.conf

      http{

        server

        {

          listen       80;

          server_name  www.web1.com

          .......

          location /

          {

            uwsgi_pass 127.0.0.1:8000;

            .......

          }

        }

        server

        {

          listen       80;

          server_name  www.web2com

          .......

          location /

          {

            uwsgi_pass 127.0.0.1:8001;

            .......

          }

        }

     }

    nginx配置文件建立两个server,分别将域名请求转发至服务器两个本地端口。

    2.uwsgi

      为每个站点配置各自的配置文件,在此使用的xml格式的配置文件。ps:如果uwsgi可以像nginx一样一个配置文件搞定,就太美了。

      /opt/site1/djangoUwsgi.xml

      <uwsgi>

        <socket>127.0.0.1:8000</socket>

        <listen>80</listen>

        .......

      </uwsgi>

      /opt/site2/djangoUwsgi.xml

      <uwsgi>

        <socket>127.0.0.1:8001</socket>

        <listen>80</listen>

        .......

      </uwsgi>

    3.配置文件搞定,启动

      uwsgi -x /opt/site1/djangoUwsgi.xml

      uwsgi -x /opt/site2/djangoUwsgi.xml

      nginx -c /opt/nginx.conf

    4.关闭

      killall -QUIT uwsgi ,这样会杀死所有的站点uwsgi进程,可能有需要杀各自的进程

      @N t s同学给出了linux shell方法,在此感谢。

      line=`ps aux|grep uwsgi |grep 'uwsgi ./site1/.'|awk '{print $2}' `

      for pid in line;

      do

          kill -9 $pid;

      done

      作用是查看相关进程,取出进程号,挨个杀死。名字和字段数字可以按自己系统,自行设置。

    附:uwsgi自动重启参数:<py-autoreload>1</py-autoreload>

          官网还有其它参数:py-auto-reload    python-auto-reload    python-autoreload    py-auto-reload-ignore, 详见http://uwsgi-docs.readthedocs.org/en/latest/Options.html

  • 相关阅读:
    bzoj3530 [SDOI2014]数数
    bzoj3940 Censoring
    线性代数基础
    hdu1085 Holding Bin-Laden Captive!
    hdu1028 Ignatius and the Princess III
    luogu2000 拯救世界
    博弈论入门
    树hash
    luogu2173 [ZJOI2012]网络
    luogu1501 [国家集训队]Tree II
  • 原文地址:https://www.cnblogs.com/pythonClub/p/9827225.html
Copyright © 2011-2022 走看看