zoukankan      html  css  js  c++  java
  • django wsgi nginx 配置

    """
    WSGI config for HelloWorld project.
    
    It exposes the WSGI callable as a module-level variable named ``application``.
    
    For more information on this file, see
    https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
    """
    
    import os,sys
    
    os.environ['PYTHON_EGG_CACHE'] = '/data/wwwroot/HelloWorldroot/.python-eggs'
    
    reload(sys)
    from django.core.wsgi import get_wsgi_application
    
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "HelloWorld.settings")
    
    application = get_wsgi_application()
    
    if __name__ == "__main__":
        HelloWorld.run()

    演示的是django HelloWorld项目启动,上面的是位于/data/wwwroot/HelloWorldroot/HelloWorld/wsgi.py

    [uwsgi]
    #socket = 127.0.0.1:9666 #设置监听的端口
    socket = /tmp/HelloWorld_uwsgi.sock #设置使用sock
    #修改文件后自动重启,触发时间3秒
    py-autoreload=3
    pidfile=/tmp/HelloWorld-master.pid
    master=true
    vhost=true
    #项目目录
    chdir=/data/wwwroot/HelloWorldroot/
    module=HelloWorld.wsgi
    #最大请求数 max
    -requests = 5000
    #启动的用户
    gid=www
    uid=www
    uwsgi_read_timeout=600 # 指定接收uWSGI应答的超时时间,完成握手后接收uWSGI应答的超时时间,单位秒。
    harakiri=1200 #请求超时时间,单位秒

    上面的是位于/data/wwwroot/HelloWorldroot/uwsgi.ini

    配置supervisor

    vi /etc/supervisord.d/HelloWord.ini

    [program:HelloWord]
    user=root
    command=/usr/local/bin/uwsgi /data/wwwroot/HelloWorldroot/uwsgi.ini -l 128 -p 400 --buffer-size 32768 #l 设置套接字侦听队列大小,-p 生成指定数量的workers/processes,buffer-size uwsgi包解析的内部缓存区大小#检测进程停止的信号
    stopsignal=QUIT
    #启动supervisord的时候自动启动
    autostart=true
    autorestart = true
    redirect_stderr=true
    stdout_logfile=/data/wwwroot/HelloWorldroot/uwsgi.log
    stderr_logfile=/data/wwwroot/HelloWorldroot/uwsgi_error.log

    supervisorctl  reload #重新加载配置

    supervisorctl status 查看启动状态

    使用socket = /tmp/HelloWorld_uwsgi.sock 则使用代理访问,监听端口可以直接访问端口

    nginx 配置

    server {
    
            listen   80;
            server_name 域名;
            access_log /data/wwwroot/HelloWorldroot/logs/access.log;
            error_log /data/wwwroot/HelloWorldroot/logs/error.log;
        
        location / {
             include        uwsgi_params;
         #uwsgi_pass     127.0.0.1:9666;
             uwsgi_pass     unix:/tmp/HelloWorld_uwsgi.sock;
            }
        #静态文件路径
        location /static/ {
                alias  /data/wwwroot/HelloWorldroot/HelloWorld/static/;
            }
    }
  • 相关阅读:
    cmd中输入vue ui不起作用
    win10下如何让别人访问自己的数据库,开放3306端口
    maven出现报错:Failed to execute goal on project ***** Could not resolve dependencies for project com.**.**.**:jar:0.0.1-SNAPSHOT: Could not find artifact:jar:1.0-SNAPSHOT -> [Help 1]
    vue中改变字体大小,px不起作用
    vue安装教程
    Springboot快速入门
    【POI】Excel数据导入
    【MySQL】替换件需求
    【Git】Gitlab仓库访问拒绝,SSL校验影响
    【MySQL】java.sql.SQLException: Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='
  • 原文地址:https://www.cnblogs.com/cainiaoit/p/8873318.html
Copyright © 2011-2022 走看看