首页 > 服务器中uwsgi如何与flask项目启动的端口关联?还有nginx,uwsgi,flask项目三者是如何关联起来工作的?

服务器中uwsgi如何与flask项目启动的端口关联?还有nginx,uwsgi,flask项目三者是如何关联起来工作的?

自己写好了flask的项目,放在了服务器上,现在服务器本地上可以运行我的项目,但是flask项目的端口是127.0.0.1:5000,我的uwsgi配置文件是这样的

[uwsgi]

socket = 127.0.0.1:8001 

chdir = /home/www/

wsgi-file = manage.py 

callable = app 

processes = 4

threads = 2

stats = 127.0.0.1:5000   #这个stats是写flask项目的端口吗?

nginx的配置文件是这样的

events {

    worker_connections  1024;

}

http {
    include       mime.types;
    default_type  application/octet-stream;
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;

    server {

        listen       80;
        server_name  xxx.xxx.xxx.xxx;#我的公网ip
        #charset koi8-r;
        access_log  /home/www/WebBlogold/logs/access.log;
        error_log  /home/www/WebBlogold/logs/error.log;

        location / {

            include        uwsgi_params;

            uwsgi_pass     127.0.0.1:8001;

            uwsgi_param UWSGI_PYHOME /home/www/WebBlogold/venv;

            uwsgi_param UWSGI_CHDIR  /home/www/WebBlogold;

            uwsgi_param UWSGI_SCRIPT manage:app;

        }
    }
}

uwsgi的配置文件和nginx的配置文件有没有错误啊?
我的nginx和uwsgi都是在全局安装的,没有在virtualenv创造的venv环境下安装。
这里我怎么启动项目,是用uwsgi启动吗?(我在服务器上运行了uwsgi的配置文件之后,访问我的公网ip地址,一直没有反应)
我现在只知道服务器要先经过nginx然后再经过uwsgi才能访问到我的项目,但具体是怎么实现的呢?看了好多部署flask项目方面的教程,一般只是一步一步告诉我怎么做,并没有说的太详细,我按照他们说的一步步配置之后一头雾水,希望大家教教我,这里先谢谢了!!!


request->nginx->uwsgi->flask 

如果你想直接使用uwsgi测试,请使用http参数比如 uwsgi --http 0.0.0.0:80

浏览器才能和uwsgi沟通

否则 浏览器是无法和uwsgi直接沟通的

【热门文章】
【热门文章】