• nginx反向代理uwsgi django服务器搭建总结


    1.安装python、django、虚拟环境
    参考帖子:安装python django
    https://blog.csdn.net/a249900679/article/details/51527200

    安装配置虚拟环境:
    https://www.cnblogs.com/technologylife/p/6635631.html
    其他参考网页:
    https://www.cnblogs.com/levelksk/p/7921066.html
    https://blog.csdn.net/m0_37687051/article/details/75267679
    2. 安装uwsgi
    pip install uwsgi
    3. 安装nginx
    wget http://nginx.org/download/nginx-1.13.7.tar.gz
    4. 配置wsgi,并启动

    # myweb_uwsgi.ini file
    [uwsgi]

    # Django-related settings

    socket = :8000

    # the base directory (full path)
    chdir = /home/sites/blogproject

    # Django s wsgi file
    module = blogproject.wsgi

    # process-related settings
    # master
    master = true

    # maximum number of worker processes
    processes = 4

    # ... with appropriate permissions - may be needed
    # chmod-socket = 664
    # clear environment on exit
    vacuum = true
    uwsgi --ini blogproject_uwsgi.ini

    5. 配置nginx代理真实服务器
    nginx.conf /usr/local/nginx/conf/nginx/conf
    server {
    listen 8099;
    server_name 127.0.0.1;
    charset UTF-8;
    access_log /var/log/nginx/myweb_access.log;
    error_log /var/log/nginx/myweb_error.log;

    client_max_body_size 75M;

    location / {
    include uwsgi_params;
    uwsgi_pass 127.0.0.1:8000;
    uwsgi_read_timeout 2;
    }
    location /static {
    expires 30d;
    autoindex on;
    add_header Cache-Control private;
    alias /home/sites/blogproject/static/; # 关联项目静态文件
    }
    }

    nginx
    nginx -s stop
    nginx -s reload

    pip freeze > requirements.txt # 记录项目依赖
    virtualenv --python=python3 env # 创建虚拟环境
    source env/bin/activate
    pip install -r requirements.txt # 安装项目依赖
    python manage.py collectstatic # 收集静态文件 要在setting中配置STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    DEBUG = False
    ALLOWED_HOSTS = ['127.0.0.1', 'localhost ', '.zmrenwu.com']
    python manage.py migrate #生成数据库

    https://www.cnblogs.com/frchen/p/5709533.html
    https://www.zmrenwu.com/post/20/

  • 相关阅读:
    loadrunne-- Analysis 分析器
    Fiddler抓包工具详细介绍
    在 Windows 10 x64 上安装及使用 ab 工具的流程
    Ab工具基本使用
    ab压测返回结果解析
    VMware Workstation 14 Pro永久激活密钥
    通用接口测试用例设计
    线段树の二 区间乘+区间加
    线段树の一 区间和
    C++位运算
  • 原文地址:https://www.cnblogs.com/wuchenggong/p/9384017.html
Copyright © 2020-2023  润新知