zoukankan      html  css  js  c++  java
  • nginx+uwsgi环境部署

    WSGI

    django自带的wsgiref 在调试模式下使用的wsgi的文件,网关接口,协议
    
    uwsgi:协议
    
    uWSGI:具体实现方式

    安装

    ```
    pip3 install uwsgi -i https://pypi.douban.com/simple
    ```

    准备django程序

    启动

    ```
    cd django目录
    uwsgi --http :8080 --module mysite.wsgi
    ```

    配置文件格式

    ```
    conf
    py
    cnf
    xml
    json
    ini
    yaml
    ```

    配置文件启动#创建uwsgi配置文件

    Vim filepath/uwsgi.ini 


    ``` [uwsgi] http
    = :8080 #项目路径 chdir= /data/mysite # uwsgi的文件 wsgi-file= mysite/wsgi.py # 虚拟环境 # virtualenv = /root/env # 进程个数 processes = 2 # 线程个数 threads=2 # 后台启动,指定日志的输出 daemonize=/data/mysite/django.log # 清除临时文件 vacuum = true # python文件发生改变自动重启 py-autoreload=1 ```


    #通过配置文件启动uwsgi

    uwsgi --ini file
     

    nginx的配置文件

    ```
    server {
      listen 80;
      server_name crm.oldboy.com;
      location / {
        proxy_pass http://127.0.0.1:8080;
      }
      location /static {
        root /data/supercrm;
      }
    }
    ```

    在django的配置中要写入

    ```shell
    SATAIC_ROOT=os.path.join(BASE_DIR,'static/')
    ```

    执行命令

    ```SHELL
    python3 manager.py collectstatic #用来收集静态文件
    ```

    第二种配置方式

    ```shell
    uwsgi
    socket= :9090
    nginx的配置文件
    location / {
    include uwsgi_params;
    uwsgi_pass 127.0.0.1:8080;
    }
    ```

    第三种配置方式

    ```shell
    uwsgi
    socket = file.sock
    nginx的配置文件
    location /{
    include uwsgi_params;
    uwsgi_pass unix://file.sock
    }
    ```
  • 相关阅读:
    CSS:命名规范心得分享
    css中用一张背景图做页面的技术有什么优势?
    ie8 css hack
    简单介绍几个CSSReset的方法
    牛人也得看的CSS常识
    DIV+CSS网页布局常用的一些基础知识整理
    font-size:100%有什么作用?
    为什么无法定义1px左右高度的容器
    Div+CSS常见错误总结
    从数字千分位处理认识(?<=)、(?=)、(?:)
  • 原文地址:https://www.cnblogs.com/sun-10387834/p/12797321.html
Copyright © 2011-2022 走看看