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.