0x00 Head
Used to like using Ubuntu, but the actual deployment of the project laboratory is still required to use CentOS, had to put it again, midway encountered a lot of pits, make a note for later inquiries, do not want to go over the pile of bookmarks, a mess, or their summary of things look comfortable. 0x01 Mount Pip and Easy_install
Install Easy_install
Wget-q http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
Install PIP
Install dependencies First:
Yum Groupinstall "Development tools" Yum install zlib zlib-devel bzip2-devel openssl-devel
Sqlite-devel Readline-devel Tk-devel
wget--no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
tar zvxf 1.5.5.tar.gz
CD pip-1.5.5/
python setup.py install
0x02 Installation Uwsgi
Pip Install Uwsgi
To create a profile in the root directory of the project:
Vim Config.ini
Fill in the following content:
[Uwsgi]
Socket = 127.0.0.1:8001//The address and port used when starting the program
chdir =/home/www/ //Your project directory
wsgi-file = manage.py // Flask Program Boot file
callable = Application variable name
processes = 2//number of processors enabled in app//program
threads = 4 // Number
of threads stats = 127.0.0.1:9191 //Get service address for UWSGI statistics
For Wsgi's role in Web services, see here: Introduction to Python Wsgi
To start the service:
Uwsgi Config.ini
0x03 Installation Nginx
To configure the source and install:
Yum install yum-fastestmirror
yum install Nginx
To view the configuration file for Nginx application:
Nginx-t
We need to change the location of the configuration file as follows (note that you need to change the place, the rest of the place according to your needs to change):
server {
listen ;
server_name www.test.com; # Nginx will ignore this option when only one server is available, so just fill in the
access_log /logs/python.flask.access.log; # Log Location
location/{
include uwsgi_params;
Uwsgi_pass 127.0.0.1:8001;
Uwsgi_param Uwsgi_pyhome/usr/bin/python; # Point to the Virtual Environment directory (I do not use the virtual environment, write directly the location of the Python program)
uwsgi_param uwsgi_chdir /usr/apps/python/your_pro; # point to the site root directory
Uwsgi_param Uwsgi_script Manage:app; # Specify startup program
}
Change the rest as needed.
After opening the UWSGI, continue to open the Nginx, the basic configuration is OK. 0x04 Installation Supervisor
After the above configuration, in fact, your site has been able to visit the normal, speed swish. But there are many times there will be accidents, uwsgi hang up how to do. This time you need a daemon program to help you restart it.
Supervisor is a process management tool, the popular point is to help you monitor a process, if found that it hung, immediately to continue it.
Installation:
Pip Install Supervisor
Build configuration file:
cd/usr/bin/
./echo_supervisord_config >/etc/supervisord.conf
Next modify the configuration file, in the configuration file, the annotation character, and remove the preceding semicolon:
[Program:project_name] # PROJECT_NAME for the project name command
= Uwsgi--ini/home/flask/config.ini # Write the command to start UWSGI here, replace the config.ini path with an absolute path
Stopsignal=quit
autostart=true
autorestart=true
stdout_logfile=/var/log/uwsgi/supervisor_flask.log # Run Log
stderr_logfile=/var/log/uwsgi/supervisor_flask_err.log # error log
Start:
Supervisord-c/etc/supervisord.conf
Then look at the UWSGI process first:
PS aux | grep Uwsgi
Kill it, then PS to see the process is not:
Killall Uwsgi
Finish.
Finally put on a picture of Meimei, the interface with the sister UI:
Reference Document:
HTTP://WWW.TUICOOL.COM/ARTICLES/EJM2U2
http://www.cnblogs.com/dspace/archive/2016/07/06/ 5647587.html
https://segmentfault.com/a/1190000004294634