zoukankan      html  css  js  c++  java
  • Python 部署 flask 用uwsgi和nginx

    安装uwsgi nginx 具体方法请百度

    1.在项目目录下建立.ini文件

    xad_uwsgi.ini

    [uwsgi]
    master=true
    #项目目录
    chdir=/root/zhaoyingjie/xadconf
    #虚拟环境
    virtualenv=/root/zhaoyingjie/pyenv/xadconf
    #module=xadserver
    #plugins=python
    #所需要运行的文件
    mount=/=main.py
    manage-script-name=true
    # TODO
    py-autoreload=0
    lazy-apps=true
    callable=app
    #与nginx通信的接口
    socket=127.0.0.1:5012
    
    # TODO
    #master = true
    #所起几个进程
    processes=8
    #确保文件路径存在 存主进程号
    pidfile = /root/zhaoyingjie/xadconf/xadserver_uwsgi.pid
    #threads = 2
    
    # threads=2
    buffer-size=32768
    
    #确保路径文件在
    daemonize = /root/zhaoyingjie/xadconf/uwsgi.log
    log-maxsize = 1000000
    log-truncate = true
    disable-logging = true
    
    

    2配置nginx文件

    在此路径下建立对应文件如果没有请自行创建 xadconf.test.com为二级域名

    /etc/nginx/sites-enabled/xadconf.test.com

    #xadconf.test.com 内容为 
    server {
        listen 80;
       #域名或ip
        server_name xadconf.test.com;
        #存放log的相对路径
        root /data2/output/;
          autoindex on;
          location /xad_debug {
              return 404;
          }
          location /xad_err_request {
              return 404;
          }
          location /favicon.ico {
              return 404;
          }
          location / {
            include        uwsgi_params;
            uwsgi_pass     127.0.0.1:5012;
        }
        #存放log路径
        access_log /data2/output/logs/xadconf/access.log;
        error_log /data2/output/logs/xadconf/error.log;
        disable_symlinks off;
        charset utf-8;
     }

    3.在完成上面配置后,需要按以下步骤来做:重启Nginx服务器,以使Nginx的配置生效。

    nginx -s  reload

    4.回到项目跟目录启动uwsgi

    uwsgi -i XX.ini

    5. ps aux | grep uwsgi 检查uwsgi的进程

    6.kill -9 进程号  杀死 uwsgi的进程

      

  • 相关阅读:
    rand()和srand()
    advanced regression to predict housing prices
    数学建模
    python的对数
    八月总结——人工智能初学者
    看到的不错的项目
    学习笔记(七): Logistic Regression
    学习笔记(六): Regularization for Simplicity
    An Intuitive Explanation of Convolutional Neural Networks
    CentOS7的mysql5.7-rpm.bundle方式安装
  • 原文地址:https://www.cnblogs.com/zhaoyingjie/p/8710482.html
Copyright © 2011-2022 走看看