Skip to content
Myr

Merge pull request #1558 from JonasGroeger/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Update uwsgi/nginx deployment documentation

authored by Armin Ronacher · committed by Armin Ronacher · parents 7d6e118, b644e27 · Browse files · 1 file+18 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+18 added−9 removed

  • other:+18 added−9 removed

1 file+18 added−9 removed

modified:docs/deploying/uwsgi.rst+18 added-9 removed
27 unmodified lines
28Given a flask application in myapp.py, use the following command:2930.. sourcecode:: text3132 $ uwsgi -s /tmp/uwsgi.sock --module myapp --callable app32 $ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app3334Or, if you prefer:3536.. sourcecode:: text3738 $ uwsgi -s /tmp/uwsgi.sock -w myapp:app38 $ uwsgi -s /tmp/uwsgi.sock --manage-script-name --mount /yourapplication=myapp:app3940The ``--manage-script-name`` will move the handling of ``SCRIPT_NAME`` to41uwsgi, since its smarter about that. It is used together with the ``--mount``42directive which will make requests to ``/yourapplication`` be directed to43``myapp:app``, where ``myapp`` refers to the name of the file of your flask44application (without extension). ``app`` is the callable inside of your45application (usually the line reads ``app = Flask(__name__)``.4647If you want to deploy your flask application inside of a virtual environment,48you need to also add ``--virtualenv /path/to/virtual/environment``. You might49also need to add ``--plugin python`` or ``--plugin python3`` depending on which50python version you use for your project.5152Configuring nginx53-----------------5443A basic flask uWSGI configuration for nginx looks like this::55A basic flask nginx configuration looks like this::5657 location = /yourapplication { rewrite ^ /yourapplication/; }58 location /yourapplication { try_files $uri @yourapplication; }59 location @yourapplication {60 include uwsgi_params;49 uwsgi_param SCRIPT_NAME /yourapplication;50 uwsgi_modifier1 30;51 uwsgi_pass unix:/tmp/uwsgi.sock;61 uwsgi_pass unix:/tmp/yourapplication.sock;62 }6364This 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::65to have it in the URL root its a bit simpler::6667 location / { try_files $uri @yourapplication; }68 location @yourapplication {69 include uwsgi_params;61 uwsgi_pass unix:/tmp/uwsgi.sock;70 uwsgi_pass unix:/tmp/yourapplication.sock;71 }7273.. _nginx: http://nginx.org/74.. _lighttpd: http://www.lighttpd.net/
2 unmodified lines