• 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

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

  • 相关阅读:
    如何解决Windows 10系统下设备的声音问题
    mutex与semaphore的区别
    大端与小端,大尾与小尾,高尾端与低尾端,主机字节序与网络字节序
    详解C语言的htons和htonl函数、大尾端、小尾端
    sockaddr与sockaddr_in结构体简介
    使用socket()函数创建套接字
    struct socket 结构详解
    C语言函数sscanf()的用法
    使用 Socket 通信实现 FTP 客户端程序(来自IBM)
    C语言文件的读写
  • 原文地址:https://www.cnblogs.com/iamjqy/p/7449214.html
Copyright © 2020-2023  润新知