uwsgi.rst
This file
Path
docs/deploying/uwsgi.rst
67 lines · 2.2 KiB
Last changed by
Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae
History of this fileTake it
The walk stopped after 200 commits: lines older than 51d7c8d point at it.
Merge branch 'master' of github.com:mitsuhiko/flaskArmin Ronacherbefore adoption51d7c8d
lines 1–53why, one step back1.. _deploying-uwsgi:23uWSGI4=====56uWSGI is a deployment option on servers like `nginx`_, `lighttpd`_, and7`cherokee`_; see :ref:`deploying-fastcgi` and :ref:`deploying-wsgi-standalone`8for other options. To use your WSGI application with uWSGI protocol you will9need a uWSGI server first. uWSGI is both a protocol and an application server;10the application server can serve uWSGI, FastCGI, and HTTP protocols.1112The most popular uWSGI server is `uwsgi`_, which we will use for this13guide. Make sure to have it installed to follow along.1415.. admonition:: Watch Out1617 Please make sure in advance that any ``app.run()`` calls you might18 have in your application file are inside an ``if __name__ ==19 '__main__':`` block or moved to a separate file. Just make sure it's20 not called because this will always start a local WSGI server which21 we do not want if we deploy that application to uWSGI.2223Starting your app with uwsgi24----------------------------2526`uwsgi` is designed to operate on WSGI callables found in python modules.2728Given a flask application in myapp.py, use the following command:2930.. sourcecode:: text3132 $ uwsgi -s /tmp/uwsgi.sock --module myapp --callable app3334Or, if you prefer:3536.. sourcecode:: text3738 $ uwsgi -s /tmp/uwsgi.sock -w myapp:app3940Configuring nginx41-----------------4243A basic flask uWSGI configuration for nginx looks like this::4445 location = /yourapplication { rewrite ^ /yourapplication/; }46 location /yourapplication { try_files $uri @yourapplication; }47 location @yourapplication {48 include uwsgi_params;49 uwsgi_param SCRIPT_NAME /yourapplication;50 uwsgi_modifier1 30;51 uwsgi_pass unix:/tmp/uwsgi.sock;52 }53Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae
line 54why, one step back54This configuration binds the application to ``/yourapplication``. If you wantMerge branch 'master' of github.com:mitsuhiko/flaskArmin Ronacherbefore adoption51d7c8d
line 55why, one step back55to have it in the URL root it's a bit simpler because you don't have to tellMerge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae
line 56why, one step back56it the WSGI ``SCRIPT_NAME`` or set the uwsgi modifier to make use of it::Merge branch 'master' of github.com:mitsuhiko/flaskArmin Ronacherbefore adoption51d7c8d
lines 57–65why, one step back5758 location / { try_files $uri @yourapplication; }59 location @yourapplication {60 include uwsgi_params;61 uwsgi_pass unix:/tmp/uwsgi.sock;62 }6364.. _nginx: http://nginx.org/65.. _lighttpd: http://www.lighttpd.net/Merge pull request #1132 from nicorevin/update_linksDaniel Neuhäuserbefore adoption8d3ee01
line 66why, one step back66.. _cherokee: http://cherokee-project.com/Merge branch 'master' of github.com:mitsuhiko/flaskArmin Ronacherbefore adoption51d7c8d
line 67why, one step back67.. _uwsgi: http://projects.unbit.it/uwsgi/