Tutorials for configuring Nginx+python environments on Linux systems via UWSGI

Source: Internet
Author: User
1. Install Ubuntu with Uwsgi PPA:

2. Replace Mod_wsgi with Uwsgi

Nginx's overall configuration here does not say, assuming already understand Nginx basic configuration, then UWSGI is similar to this configuration:

  Location/{    include uwsgi_params    uwsgi_pass 127.0.0.1:9090   

Another example is Django:

.......  From Django.core.handlers.wsgi import Wsgihandler  

Then run Uwsgi listening 9090, where-W followed by the module name, which is the MyApp just configured

Running Web site discovery has been deployed.

Parameters of 3.uwsgi

These are the simplest deployments of a single project, and Uwsgi still has a lot of admirable features, such as:

Concurrent 4 Threads:

Master control thread + 4 threads:

Perform a direct abort of the client for more than 30 seconds:

Limit Memory space 128M:

Service more than 10,000 req automatic respawn:

Background run, etc.:

4. Configure multiple sites for UWSGI

In order for multiple sites to share a UWSGI service, the UWSGI must be run as a virtual site: Remove the "-w MyApp" plus "–vhost":

Then you must configure VIRTUALENV,VIRTUALENV to be a useful virtual environment tool for Python to install:

Then set up one or more app baseline environments:

Application environment, the software installed in this environment is only valid in this environment:

Source/var/www/myenv/bin/activate  pip install Django  pip install Mako  

Last configuration Nginx, note that each site must occupy a single server, the same server different location directed to different applications do not know why always fail, estimation is a bug.

    server {      listen    ;      server_name app1.mydomain.com;      Location/{          include uwsgi_params;          Uwsgi_pass 127.0.0.1:9090;          Uwsgi_param uwsgi_pyhome/var/www/myenv;          Uwsgi_param Uwsgi_script MyApp1;          Uwsgi_param uwsgi_chdir/var/www/myappdir1;      }    }    server {      listen    ;      server_name app2.mydomain.com;      Location/{          include uwsgi_params;          Uwsgi_pass 127.0.0.1:9090;          Uwsgi_param uwsgi_pyhome/var/www/myenv;          Uwsgi_param Uwsgi_script myapp2;          Uwsgi_param Uwsgi_chdir/var/www/myappdir2;      }    

In this way, to restart the Nginx service, two sites can share a UWSGI service.

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