zoukankan      html  css  js  c++  java
  • virtualenv下配置nginx uwsgi Django

    1.安装virtualenv,创建虚拟环境django15

    sudo apt-get install virtualenv

    virtualenv env

    source bin/active

    pip install django1.5.1

    2.安装uwsgi

    pip install uwsgi等

    3.将tcweb拷贝到django15虚拟环境中,建立uwsgi配置

    tc_uwsgi.ini
    [uwsgi]
    vhost = false #注意多个项目的时候不能true哦,否则多个项目都共用这个配置参数了,这个很折腾人
    plugins = python
    #socket = 127.0.0.1:9000 #这个注释掉了,我采用sock的方式,当然你可以使用端口方式,nginx配置的时候修改一下即可
    socket = /opt/django15/proj_uwsgi.sock #配置文件用到的sock文件
    master = true
    enable-threads = true
    workers = 2 #进程数
    wsgi-file = /opt/django15/myproj/myproj/wsgi.py  #这是项目wsgi.py文件的路径
    virtualenv = /opt/django15/   #虚拟环境的路径
    chdir = /opt/django15/tcweb  #下myproject项目的路径

    启动uwsgi

    nohup uwsgi --ini myproj_uwsgi.ini --pidfile=./uwsgi-master.pid& #--pidfile指定进程

    重启uwsgi

    kill -TERM `cat ./uwsgi-master.pid`

    4.nginx配置

    server{
        listen 8088;
        server_name tt.com;
    
        access_log /opt/django15/logs/access.log;
        error_log /opt/django15/logs/error.log;
    
        root /opt/django15/myproj;
        index index.html index.htm;
    
        charset utf-8;
    
        location ~^/static/
        {
            root /opt/django15/myproj/;
            expires 24h;
            access_log off;
        }
    
        location ~^/media/
        {
            root /opt/django15/myproj/;
            expires 24h;
            access_log off;
        }
    
        location /{
            uwsgi_pass 127.0.0.1:9000;
            include uwsgi_params;
            #proxy_http_version 1.1;
        }
    }
  • 相关阅读:
    又一种Mysql报错注入
    PHP wget 增强脱裤脚本(PDO MYSQL)
    一种少见的跨目录写webshell方法
    过狗一句话
    在myql sqlserver里边怎么快速找到带有关键字的表
    php读取3389脚本
    学习OpenCV,看这些!
    Git 学习看这篇就够了!
    开发工具使用技巧和插件大总结
    (资源整理)带你入门Spark
  • 原文地址:https://www.cnblogs.com/zeng-wei/p/3687489.html
Copyright © 2011-2022 走看看