Configuring Uwsgi+nginx servers for Flask framework sites in Linux
There are myproject programs in the home/admin/directory with hello.py
1 Installing PIP
wget "HTTPS://PYPI.PYTHON.ORG/PACKAGES/SOURCE/P/PIP/PIP-1.5.4.TAR.GZ#MD5=834B2904F92D46AAA333267FB1C922BB"-- No-check-certificate
# TAR-XZVF Pip-1.5.4.tar.gz
# CD pip-1.5.4
# python setup.py Install
or Yum Installpip
2 Installing Nginx
cd/usr/local/
wget http://nginx.org/download/nginx-1.2.8.tar.gz
TAR-ZXVF nginx-1.2.8.tar.gz
CD nginx-1.2.8
./configure --prefix=/usr/local/nginx
Make
Make install
3 Installing UWSGI
Pip Install Uwsgi
Configure the Web server
Add Config.ini under the MyProject project file
Content is;
[Uwsgi]
Socket = 127.0.0.1:8001 #注: Specify a fixed port
processes = 4 #注: Run a few processes, here with 4 processes
Threads = 2
Master = True
Pythonpath =/home/admin/myproject
module = Hello
Callable = App
Memory-report = True
Save: Press Escape first to add ": Wq"
Modify nginx.conf content in/usr/local/nginx/conf/
server {
Listen 8080;
server_name 127.0.0.1;
Root/home/admin/myproject;
location/{
Uwsgi_pass 127.0.0.1:8001;
Include/usr/local/nginx/conf/uwsgi_params;
}
Start Uwsgi:
Uwsgi–ini/home/admin/myproject/config.ini
Start Nginx:
Make sure that the 80 port of the system is not occupied by other programs.
/usr/local/nginx/sbin/nginx
Enter in the browser: 127.0.0.1:8080 can access
If other hosts in the LAN need access, you need to set up a Linux server firewall so that the port number 8080 is passed
The above describes the Linux in the Flask framework for the configuration of the Uwsgi+nginx server, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.