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

  • 相关阅读:
    js组件之间的通信
    localStorage, localforage, web sql三者的比较
    最近的学习计划
    无状态的web应用
    转 :meta name的含义:<META http-equiv=Content-Type content="text/html; charset=gb2312">
    css清除浮动的方法汇总
    segfault at 7fff6d99febc ip 0000003688644323 sp 00007fff6d99fd30 error 7 in libc.so.6[3688600000+175000]
    Linux内核定时器
    TCPIP网络协议层对应的RFC文档
    UIDocumentPickerViewController使用
  • 原文地址:https://www.cnblogs.com/pythonClub/p/9827225.html
Copyright © 2011-2022 走看看