centos6.8 Build Nginx+uwsgi+flask

Source: Internet
Author: User

1. Installation

Yum Install Nginx-y

PIP3 Install Uwsgi
PIP3 Install Flask

2.UWSGI configuration (Save/etc/uwsgi.ini,run:uwsgi/etc/uwsgi.ini)

[uwsgi]# Uwsgi the address and port used to start the socket= point to Site Directory chdir=/app/db_cache_server/# Number of processors processes=2#查看uwsgi状态, a statusstats like Nginx= python launcher file Wsgi-file =the name of the application variable to start within the db_cache_api.py# Python program. Callable=The app is a variable within the manage.py program file, and the type of the variable is flask application class. Callable=app# causes the process to run in the background and hits the log to the specified log file or to the UDP server (Daemonize uwsgi). In fact, the most common thing is to output the running record to a local file. Daemonize= /var/log/uwsgi_httpserver.log# Specifies the location of the PID file and records the PID number of the main process. Pidfile=/tmp/uwsgi.pid# automatically cleans up the environment when the server exits, removes the UNIX socket file and the PID file vacuum=true#以固定的文件大小 (in kilobytes), the cut log file. Log-maxsize =50000000#不记录请求信息的日志. Only errors and UWSGI internal messages to the log are logged. Disable-logging =true

3.nginx Configuration

server {        listen       8080;         server_name  139.196. 105.160 ;          / {             try_files $uri @uwsgi;         }         #定义uwsgi块 location         @uwsgi {             include uwsgi_params;              127.0. 0.1:50000;         }     }

4. Installing Supervisor

Yum Install Supervisor-y

The global configuration file location of the Supervisor is in:


Under normal circumstances we do not need to make any changes to it, just add a new *.conf file to put in:


Next, we'll create a new supervisor configuration for the Uwsgi to start the My_flask project (named: my_flask_supervisor.conf):

[program:my_flask]# Start command gate=/home/www/my_flask/venv/bin/uwsgi/home/www/my_flask/config.ini# Command program directory=/home/www/my_flask# Run command username user=root        autostart=true  AutoRestart=true#日志地址stdout_logfile=/home/www/my_flask/logs/uwsgi_supervisor.log
Start the service
sudo service supervisor Start
Termination of Service
sudo service supervisor Stop

Reference: Http://www.tuicool.com/articles/zUvqMr

centos6.8 Build Nginx+uwsgi+flask

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.