zoukankan      html  css  js  c++  java
  • python+uwsgi+nginx部署

    nginx安装

    安装工具 
    yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel
    安装pcre
    wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
    tar xzf  pcre-8.35.tar.gz -C /usr/local/src/
    cd pcre-8.35
    ./configure
    make && make install
    pcre-config --vesrion
    安装nginx
    wget http://nginx.org/download/nginx-1.17.7.tar.gz
    tar xzf nginx-1.17.7.tar.gz
    cd nginx-1.17.7
    ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
    make
    make install
    /usr/local/webserver/nginx/sbin/nginx -v
    创建www用户组和用户
    groupadd www
    useradd -g www www

    nginx配置

    /etc/nginx/conf.d/default.conf
    location /v1/line {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:9000;  #unix:/.../tmp/uwsgi.sock;
    }
    location /v1/jacoco {
            rewrite ^/v1/jacoco/(.*)$ /$1 break;
            proxy_pass http://127.0.0.1:9000;
            proxy_set_header Host  $host;
            proxy_set_header X-Real-Ip $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
            add_header 'Access-Control-Allow-Methods' 'POST, GET, DELETE, OPTIONS';
    }

    检查配置: nginx -t

    /etc/nginx/nginx.conf

    user www www;
    worker_processes  4;
    error_log  /usr/local/webserver/nginx/logs/error.log  crit;
    pid        /usr/local/webserver/nginx/nginx.pid;
    events {
        use epoll;
        worker_connections  1024;
    }
    http {
      log_format ...
      sendfile        on;
      server {
        location /static/ {
                alias /usr/local/webserver/nginx/html/static/;
                autoindex on; #类似ftp,目录索引
                autoindex_exact_size on;
                autoindex_localtime on;
            }


      }
    }

    uwsgi配置

    uwsgi.ini

    [uwsgi]
    socket = 127.0.0.1:9000   ;tmp/uwsgi.sock
    pythonpath=/path/flask_pro
    py-autoreload = 1  # 代码修改自动重载
    module=server
    callable=app
    master = true         
    processes= 4
    threads= 2
    pidfile=uwsgi.pid
    daemonize=uwsgi.log

    [test]
    ini = :uwsgi
    uid = www
    gid = www
    processes = 1
    daemonize = /.../log/test.log

    [uwsgi]
    # 配置uwsgi监听的socket(ip+端口)
    http-socket=:9090
    harakiri=60 # 服务器响应时间
    http-timeout=60 # 连接时间,客户端与服务器断开连接时间

    procname-prefix-spaced=%c
    wsgi-file=apps/%c/run.py
    chdir=%d../..
    callable=app
    ;py-autoreload = 1
    master=true
    processes=2
    threads=2
    # //允许在请求中开启新线程
    enable-threads=true
    pidfile=log/uwsgi.pid
    daemonize=log/uwsgi.log
    buffer-size=65535 # 单位为k


    $ uwsgi --ini uwsgi.ini:test
    $ uwsgi --reload uwsgi.pid

    MySQL配置:

       设置密码登录root:

    update user set authentication_string=PASSWORD('000000'), plugin='mysql_native_password' where user='root';

     nginx详细配置:

    {
        listen 80;
        server_name worktest.optima-trans.net;
    
        uwsgi_read_timeout 180;
        uwsgi_connect_timeout 180;
        uwsgi_send_timeout 180;
        proxy_connect_timeout 180;
        proxy_send_timeout 180;
        proxy_read_timeout 180;
        proxy_buffer_size 64k;
    proxy_buffers
    4 32k;
    proxy_busy_buffers_size 64k;
    proxy_temp_file_write_size 64k;
    proxy_ignore_client_abort on; location
    /v1/line { include uwsgi_params; uwsgi_pass unix:/var/www/optima_line/backend/current/tmp/uwsgi.sock; } location /socket.io { include uwsgi_params; uwsgi_pass unix:/var/www/service_message_1/backend/current/tmp/uwsgi.sock; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; #proxy_set_header Connection $connection_upgrade; } }

     nginx配置文件详解: https://blog.51cto.com/853056088/2128168

  • 相关阅读:
    软件体系架构复习要点
    Operating System on Raspberry Pi 3b
    2019-2020 ICPC North-Western Russia Regional Contest
    2019 ICPC ShenYang Regional Online Contest
    2019 ICPC XuZhou Regional Online Contest
    2019 ICPC NanChang Regional Online Contest
    2019 ICPC NanJing Regional Online Contest
    Codeforces Edu Round 72 (Rated for Div. 2)
    Codeforces Round #583 (Div.1+Div.2)
    AtCoder Beginning Contest 139
  • 原文地址:https://www.cnblogs.com/ccqk/p/11260792.html
Copyright © 2011-2022 走看看