147 web server.148- different python interpreters being used.149150.. _lighttpd: http://www.lighttpd.net/151-.. _nginx: http://nginx.net/151+.. _nginx: http://nginx.org/152.. _flup: http://trac.saddi.com/flup
modified:docs/deploying/index.rst+1 added
14 unmodified lines
1516 mod_wsgi17 cgi18 fastcgi19+ uwsgi20 others
added:docs/deploying/uwsgi.rst+63 added
1+uWSGI2+=====3+4+A newly popular deployment method on servers like `cherokee`_ and `nginx`_5+is uWSGI. To use your WSGI application with uWSGI protocol you will need6+a uWSGI server first. uWSGI is both a protocol and an application server;7+the application server can serve uWSGI, FastCGI, and HTTP protocols.8+9+The most popular server is `uwsgi`_, which we will use for this guide.10+Make sure to have it installed.11+12+.. admonition:: Watch Out13+14+ Please make sure in advance that your ``app.run()`` call you might15+ have in your application file, is inside an ``if __name__ ==16+ '__main__':`` or moved to a separate file. Just make sure it's not17+ called because this will always start a local WSGI server which we do18+ not want if we deploy that application to uWSGI.19+20+Starting your app with uwsgi21+----------------------------22+23+`uwsgi` is designed to operate on WSGI callables found in python modules.24+25+Given a flask application in myapp.py, use the following command:26+27+.. sourcecode:: text28+29+ $ uwsgi -s /tmp/uwsgi.sock --module myapp --callable app30+31+Or, if you prefer:32+33+.. sourcecode:: text34+35+ $ uwsgi -s /tmp/uwsgi.sock myapp:app36+37+Configuring nginx38+-----------------39+40+A basic flask uWSGI configuration for nginx looks like this::41+42+ location = /yourapplication { rewrite ^ /yourapplication/; }43+ location /yourapplication { try_files $uri @yourapplication; }44+ location @yourapplication {45+ include uwsgi_params;46+ uwsgi_param SCRIPT_NAME /yourapplication;47+ uwsgi_modifier1 30;48+ uwsgi_pass unix:/tmp/uwsgi.sock;49+ }50+51+This configuration binds the application to `/yourapplication`. If you want52+to have it in the URL root it's a bit simpler because you don't have to tell53+it the WSGI `SCRIPT_NAME` or set the uwsgi modifer to make use of it::54+55+ location / { try_files $uri @yourapplication; }56+ location @yourapplication {57+ include uwsgi_params;58+ uwsgi_pass unix:/tmp/uwsgi.sock;59+ }60+61+.. _cherokee: http://www.cherokee-project.com/62+.. _nginx: http://nginx.org/63+.. _uwsgi: http://projects.unbit.it/uwsgi/