Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 5693b9d point at it.

Merge branch 'pr/839'Armin Ronacherbefore adoption5693b9d

lines 1–53why, one step back
1.. _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 }53

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

line 54why, one step back
54This configuration binds the application to ``/yourapplication``. If you want

Merge branch 'pr/839'Armin Ronacherbefore adoption5693b9d

line 55why, one step back
55to have it in the URL root it's a bit simpler because you don't have to tell

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

line 56why, one step back
56it the WSGI ``SCRIPT_NAME`` or set the uwsgi modifier to make use of it::

Merge branch 'pr/839'Armin Ronacherbefore adoption5693b9d

lines 57–65why, one step back
57
58 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 back
66.. _cherokee: http://cherokee-project.com/

Merge branch 'pr/839'Armin Ronacherbefore adoption5693b9d

line 67why, one step back
67.. _uwsgi: http://projects.unbit.it/uwsgi/