Configure uwsgi + nginx server for the flask framework website in Linux

Source: Internet
Author: User
Tags website server
: 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.

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.