Nginx+uwsgi Deploying multiple Python Apps

Source: Internet
Author: User
Tags virtual environment virtualenv

Reference article:

http://kb.cnblogs.com/page/86907/(Configure Nginx+uwsgi to deploy Python apps more easily)

Http://projects.unbit.it/uwsgi/wiki/VirtualHosting (Uwsgi virtualhosting Mode)

http://uwsgi-docs.readthedocs.org/en/latest/Configuration.html (Configuring Uwsgi)



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

Uwsgi-m-P 2-t--limit-as 128-r 10000-x/usr/local/nginx/conf/uwsgi.xml-d/tmp/uwsgi.log--vhost

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

Easy_install virtualenv

Then set up one or more app benchmark environments

virtualenv/www/fabric-bolt/

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

Source/www/fabric-bolt/pip Install Djangopip Install mako ...

Finally configure Nginx, note that each site must occupy a single server

    server {        listen        80;        server_name   app1.blogex.com;        location / {             root /www/fabric-bolt/lib/python2.7/site-packages/fabric_ Bolt;            include   uwsgi_ params;            uwsgi_pass   192.168.1.121:9001;            uwsgi_param  uwsgi_pyhome /www/fabric-bolt;             uwsgi_param uwsgi_chdir /www/fabric-bolt/lib/python2.7/site-packages/fabric_bolt;             uwsgi_param uwsgi_script wsgi;             access_log /usr/local/nginx/logs/access.log;         }        location /static/ {             alias /www/fabric-bolt/lib/python2.7/site-packages/fabric _bolt/work/myweb/static/;            index  index.html;}}         server {             listen       80;             server_name  app2.blogex.com;             location / {                 root /www/fabric-bolt/lib/python2.7/site-packages/fabric_bolt/ Work;                include    uwsgi_params;                 uwsgi_pass  192.168.1.121:9001;                 uwsgi_param UWSGI_PYHOME /www/fabric-bolt;                 uwsgi_param  uwsgi_chdir /www/fabric-bolt/lib/python2.7/site-packages/fabric_bolt/work;                 uwsgi_param uwsgi_script django_ Wsgi;                access_ Log /usr/local/nginx/logs/access.log;        }} 


Configuration of the Uwsgi.xml

<uwsgi><pidfile>/usr/local/nginx/conf/uwsgi.pid</pidfile><socket>192.168.1.121:9001 </socket><processes>4</processes><pythonpath>/www/fabric-bolt/lib/python2.7/ site-packages</pythonpath><pythonpath>/www/fabric-bolt/lib/python2.7/site-packages/fabric_bolt< /pythonpath><pythonpath>/www/fabric-bolt/lib/python2.7/site-packages/fabric_bolt/work</pythonpath ><daemonize>/tmp/uwsgi.log</daemonize></uwsgi>


Restart Nginx Service, two sites can share a UWSGI service.


Conclusion:

The previous article has configured the DNS server, here to visit Nginx Virtual host app1.blogex.com and app2.blogex.com, you can see the Django application:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/8A/wKiom1SzlIjQ0JgJAAGwJ1iU5eg116.jpg "title=" a1.jpg "alt=" Wkiom1szlijq0jgjaagwj1iu5eg116.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/8A/wKiom1SzlOOR20EgAAGdg7tzkis005.jpg "title=" a1.jpg "alt=" Wkiom1szloor20egaagdg7tzkis005.jpg "/>

Nginx+uwsgi Deploying multiple Python Apps

Related Article

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.