I wrote the flask project myself and placed it on the server. Now my project can be run locally on the server, but the port of the flask project is 127.0.0.1:5000. My uwsgi configuration file is like this
[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 configuration file is like this
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;
}
}
}
Are there any errors in the configuration files of uwsgi and nginx?
My nginx and uwsgi are installed globally, not in the venv environment created by virtualenv.
How do I start the project here? Do I use uwsgi to start it? (After I ran the uwsgi configuration file on the server, I accessed my public IP address, but there was no response)
I now only know that the server must first go through nginx and then go through uwsgi to access my project, but specifically How is it achieved? I have read a lot of tutorials on deploying flask projects, and they usually just tell me step by step how to do it, without going into too much detail. After configuring it step by step according to what they said, I am confused. I hope you can teach me. Thank you in advance! ! !
淡淡烟草味2017-05-16 17:23:02
request->nginx->uwsgi->flask
If you want to use uwsgi to test directly, please use http parameters such as uwsgi --http 0.0.0.0:80
Only the browser can communicate with uwsgi
Otherwise, the browser cannot communicate directly with uwsgi