gpt4 book ai didi

nginx - 如何用flask和nginx启动uwsgi

转载 作者:行者123 更新时间:2023-12-03 15:33:06 26 4
gpt4 key购买 nike

我想我的主要问题是我不知道,文件层次结构应该是什么样的?到目前为止,我一直在关注 Grinberg 在他的“Flask 开发”一书中的教程。所以我喜欢:

--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中我有一行: app=create_app('default')所以这几乎就是我想我需要做的一切......

但无论如何我仍然无法摆脱上面的警告......我在没有主进程管理器的情况下运行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 服务器。

关于nginx - 如何用flask和nginx启动uwsgi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28913559/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com