Configuring Uwsgi+nginx servers for Flask framework sites in Linux

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

  • 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.