zoukankan      html  css  js  c++  java
  • Django部署uwsgi 与 nginx配置

    1、nginx文件的配置

    路径:/etc/nginx/conf.d/

    example.conf

    启动:service nginx [start]/[restart]/[stop]

    upstream django {
        # server unix:///path/to/your/mysite/mysite.sock; # for a file socket
        server 127.0.0.1:8000; # for a web port socket (we'll use this first)
    }
    
    # configuration of the server
    server {
        # the port your site will be served on
        listen      8080;
        # the domain name it will serve for
        server_name django; # substitute your machine's IP address or FQDN
        charset     utf-8;
    
        # 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;
            include     uwsgi_params; # the uwsgi_params file you installed
        }
    
        location /static{
             alias /var/www/learning_web/static;
        }
        location /static/admin {
             alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin;
        }
    
    }
    

    2、uwsgi文件的配置

    在项目的根目录下面,与manage.py同目录

    example_uwsgi.ini

    启动:uwsgi --ini example_uwsgi.ini

    # uwsgi.ini file
    [uwsgi]
    
    # Django-related settings
    # the base directory (full path)
    chdir           = /var/www/learning_web
    # Django's wsgi file
    wsgi-file       = /var/www/learning_web/learnchinese/wsgi.py
    # module       = index.wsgi:application
    # the virtualenv (full path)
    # home            = /path/to/virtualenv
    daemonize   = /var/www/learning_web/learnchinese/uwsgi.log
    # process-related settings
    # master
    master          = true
    pidfile     = /tmp/learnchinese_master.pid
    # maximum number of worker processes
    processes       = 1
    # the socket (use the full path to be safe
    # socket          = /home/python/ocean_monitor/ocean_monitor.sock
    socket          = 127.0.0.1:8000
    # ... with appropriate permissions - may be needed
    chmod-socket    = 664
    # clear environment on exit
    vacuum          = true

    停止:

    ps -aux | grep 'ecs_uwsgi.ini' | grep -v grep |cut -c 9-15|xargs kill -9

    (慎用,看清杀死的进程)

  • 相关阅读:
    zookeeperclient代码解读
    封装scrollView 循环滚动,tableViewCell(连载) mvc
    PHP经典项目案例-(一)博客管理系统5
    Android插件化(三)载入插件apk中的Resource资源
    比树莓派配置好接地气的香蕉派上手初体验
    HDU Group
    JVM 类的卸载
    JVM 自定义类加载器
    JVM 初始化阶段例子
    JVM 初始化阶段例子 final常量
  • 原文地址:https://www.cnblogs.com/iamjqy/p/7449214.html
Copyright © 2011-2022 走看看