zoukankan      html  css  js  c++  java
  • 通过nginx+uwsgi部署django应用

    上传应用

    # 创建虚拟环境
    pyenv virtualenv online
    
    # 进入工程目录,安装包
    pip install -r requirements.txt
    
    #测试
    python manage,py runserver

    访问httP://ip:8000

    安装uwsgi

    1 # 进入虚拟环境
    2 pyenv activate online
    3 
    4 pip install uwsgi
    5 
    6 # 测试uwsgi
    7 uwsgi –http :8000 –module online.wsgi

    访问httP://ip:8000

    安装nginx

    1 yum install nginx

    新建mx_nginx.conf

    upstream django {
    server 127.0.0.1:8000; # for a web port socket (we'll use this first)
    }
    
    server {
        # the port your site will be served on
        listen      80;
        # the domain name it will serve for
        server_name 47.92.37.14 www.54noob.top 54noob.top; #填你的域名或ip
        charset     utf-8;
    
        access_log /root/mxonline/logs/access.log;
        error_log /root/mxonline/logs/error.log;
    
        # max upload size
        client_max_body_size 75M;   # adjust to taste
        # Finally, send all non-media requests to the Django server.
        location / {
            uwsgi_pass  django; #一定要跟uwsgi配置的一样
            include     uwsgi_params; # the uwsgi_params file you installed
            uwsgi_param UWSGI_SCRIPT online.wsgi;  #入口文件,即wsgi.py录的位置
            uwsgi_param UWSGI_CHDIR /root/mxonline/online;       #项目根目录
        }
        access_log off;
    }

    加入nginx配置

    1 ln -s /root/mxonline/online/conf/mx_nginx.conf /etc/nginx/conf.d/

    重启nginx,这里有坑,路径不是绝对路径,链接无效

    新建mx_uwsgi.ini

    1 [uwsgi]
    2 
    3 chdir = /root/mxonline/online    #工程目录
    4 module = online.wsgi        #wsgi.py
    5 master = true
    6 processes = 10
    7 socket = 127.0.0.1:8000    #nginx配置对应
    8 vacuum = true
    9 virtualenv = /root/.pyenv/versions/online  #虚拟环境

    启动项目

    nginx     #启动nginx
    /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf   #启动redis
    
    pyenv activate online  #进入虚拟环境
    cd ~/online  #进入工程目录
    
    uwsgi -i conf/uwsgi.ini &    #启动uwsgi
    
    celery -A online worker -l info  #启动celery
  • 相关阅读:
    Java-Scanner
    Java-Stream File IO
    Java-方法
    Java-日期 正则表达式
    Java-数组
    Java-Character String StringBuffer StringBuilder
    Bootstrap栅格系统
    canvas-nest.js 设置网页背景
    Oracle数据库与MySQL的不同点
    java oop第15章_Socket网络编程
  • 原文地址:https://www.cnblogs.com/wj5633/p/6676094.html
Copyright © 2011-2022 走看看