Home >Backend Development >PHP Tutorial >Configure uwsgi+nginx server for flask framework website in Linux

Configure uwsgi+nginx server for flask framework website in Linux

WBOY
WBOYOriginal
2016-07-29 09:05:47987browse

Configuring uwsgi+nginx server for flask framework website in Linux

The myproject program exists in the home/admin/ directory, and there is hello.py in it

1 Install 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 to install 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 Install uwsgi

pip install uwsgi

Configure the website server

Add config.ini under the myproject project file

The content is;

[uwsgi]

socket = 127.0.0.1:8001 #Note: Specify a fixed port

processes = 4 #Note: Run several processes, 4 processes are used here

threads = 2

master = true

pythonpath = /home/admin/myproject

module = hello

callable = app

memory-report = true

Save: Press escape first and add ":wq"

Modify /usr/ Contents of nginx.conf in local/nginx/conf/ Root/home/admin/myproject;

Location/ {

uwsgi_pass 127.0.0.1:8001; ini /home/admin/myproject/config.ini

Start nginx :

Make sure that port 80 of the system is not occupied by other programs,

/usr/local/nginx/sbin/nginx

Enter in the browser: 127.0.0.1:8080 to access

such as other hosts in the LAN To access, you need to set up the Linux server firewall so that the set port number 8080 can pass

The above introduces the configuration of uwsgi+nginx server for the flask framework website in Linux, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn