Skip to content
Myr

uwsgi.rst

This file

Path

docs/deploying/uwsgi.rst

67 lines · 2.2 KiB

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 22af78a point at it.

Removed outdated sentence in the testing docsArmin Ronacherbefore adoption22af78a

lines 1–67why, 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 }5354This configuration binds the application to `/yourapplication`. If you want55to have it in the URL root it's a bit simpler because you don't have to tell56it the WSGI `SCRIPT_NAME` or set the uwsgi modifier to make use of it::5758 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/66.. _cherokee: http://www.cherokee-project.com/67.. _uwsgi: http://projects.unbit.it/uwsgi/