加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

如何用flask和nginx启动uwsgi

发布时间:2020-12-13 21:23:38 所属栏目:Nginx 来源:网络整理
导读:我想我的主要问题是我不知道,文件层次结构应该如何?到目前为止,我在他的“烧瓶开发”一书中关注了格林伯格的教程.所以我喜欢: --manage.py ( Flask's Script extension script)--app/ ( application folder as a package)--virtual_env 并且不确定我搞砸了

我想我的主要问题是我不知道,文件层次结构应该如何?到目前为止,我在他的“烧瓶开发”一书中关注了格林伯格的教程.所以我喜欢:

--manage.py ( Flask's Script extension script)
--app/   ( application folder as a package)
--virtual_env

并且不确定我搞砸了什么,但是现在当我用uwsgi命令尝试任何东西时,它会说出以下错误:

current working directory: /home/gaucan/temp/my_app
detected binary path: /usr/bin/uwsgi
!!! no internal routing support,rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***

编辑:
像这样开始工作:

uwsgi –http:9090 -w manage:app –enable-threads

这工作…在manage.py我有线:
应用程式= create_app( ‘默认’)
所以这就是我想我需要做的…

但我仍然无法得到上面的警告…我正在运行uwsgi没有它的主过程管理器……是否可以?或者我做错了什么?

这只是创建/etc/nginx/nginx.conf文件

    worker_processes 1;

events {

     worker_connections 1024;

}

http {

sendfile on;

gzip              on;
gzip_http_version 1.0;
gzip_proxied      any;
gzip_min_length   500;
gzip_disable      "MSIE [1-6].";
gzip_types        text/plain text/xml text/css
                  text/comma-separated-values
                  text/javascript
                  application/x-javascript
                  application/atom+xml;

# Configuration containing list of application servers
upstream uwsgicluster {

    server 127.0.0.1:8080;
    # server 127.0.0.1:8081;
    # ..
    # .

}

# Configuration for Nginx
server {

    # Running port
    listen 80;

    # Settings to by-pass for static files 
    location ^~ /static/  {

        # Example:
        # root /full/path/to/application/static/file/dir;
        root /app/static/;

    }

    # Serve a static file (ex. favico) outside static dir.
    location = /favico.ico  {

        root /app/favico.ico;

    }

    # Proxying connections to application servers
    location / {

        include            uwsgi_params;
        uwsgi_pass         uwsgicluster;

        proxy_redirect     off;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;

    }
}

}

最佳答案
这可能与您安装uwsgi的方式有关.这个警告:

!!! no internal routing support,rebuild with pcre support !!!

与您的应用程序无关,它与您的uwsgi二进制文件无关.

基本上它表示uwsgi的一部分尚未在您使用的二进制文件中启用.运行Flask应用程序不需要该特定功能,因此您可以忽略该警告.但是,如果您想了解更多信息,请参阅this question以获取有关此问题以及如何解决此问题的一些信息.

现在,关于这个其他警告:

*** WARNING: you are running uWSGI without its master process manager ***

我认为你缺少–master选项,以启用prefork服务器.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读