: This article mainly introduces how to configure uwsgi + nginx server for the flask framework website in Linux. if you are interested in the PHP Tutorial, refer to it. Configure uwsgi + nginx server for the flask framework website in Linux
The myproject program exists in the home/admin/directory, which contains hello. py.
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. 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
Content;
[Uwsgi]
Socket = 127.0.0.1: 8001 # Note: specify a fixed port
Processes = 4 # Note: run several processes. Here, four processes are used.
Threads = 2
Master = true
Pythonpath =/home/admin/myproject
Module = hello
Callable = app
Memory-report = true
Save: add ": wq" by escape first"
Modify nginx. conf 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 Port 80 of the system is not occupied by other programs,
/Usr/local/nginx/sbin/nginx
Enter 127.0.0.1: 8080 in the browser to access
If other hosts in the Lan need access, you need to set the linux server firewall so that the configured port number 8080 passes
The above introduces how to configure uwsgi + nginx server for the flask framework website in Linux, including some content, and hope to help friends who are interested in PHP tutorials.