1.flask installation
pip install flask
After using flask is developed, need to be deployed into a production environment, this time on the need to use nginx + uwsgi
2.uwsgi installation
pip install uwsgi
3. Add uwsgi.ini file uwsgi.ini edit the configuration file in the project root directory
[uwsgi] # HTTP // = 0.0.0.0:8083 only uwsgi configuration startup socket = 127.0.0.1:5000 // listening nginx forwards WSGI -file = / the Data / App / bak_handle / approval_flow / flaskr / app.py / application file / directory project a Callable = enabled application program within the app // variable names, other names may be set according to the app name processes = number of 4 // process threads = number of threads in each process 2 //
- Once configured, enter the command to start uwsgi uwsgi.ini
- No one here with the log path, because then starts the supervisor, the supervisor can view the log
- Daemon can be configured to run in supervisor, can be arranged before DETAILED DESCRIPTION Referring Django + gunicorn + supervisor 's blog
- As look at the big [uWSGI] getting INI configuration from hello_uwsgi.ini, the normal
4.nginx modify configuration files
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /data/logs/nginx/access_flow.log;
{Server the listen 8083 ; server_name localhost; #charset KOI8 - R & lt; #access_log logs / host.access.log main; LOCATION / { the include uwsgi_params; uwsgi_pass 127.0 . 0.1 : 5000 ; uwsgi_param UWSGI_CHDIR / Data / App / bak_handle / approval_flow / flaskr ; # project root directory uwsgi_param UWSGI_SCRIPT run: app; main program # start the program #root HTML; #index index.html index.htm; }
The above code is configured in a period nginx.conf nginx
Check the nginx configuration file syntax: sudo / usr / local / nginx / sbin / nginx -t
Reload nginx: sudo / usr / local / nginx / sbin / nginx -s reload
5. Start uwsgi, start nginx
This time of the visit, enter: IP: 8083
You can visit