| 1 |
=============================== |
| 2 |
How to use Django with Gunicorn |
| 3 |
=============================== |
| 4 |
|
| 5 |
Gunicorn_ ('Green Unicorn') is a pure-Python WSGI server for UNIX. It has no |
| 6 |
dependencies and can be installed using ``pip``. |
| 7 |
|
| 8 |
.. _Gunicorn: https://gunicorn.org/ |
| 9 |
|
| 10 |
Installing Gunicorn |
| 11 |
=================== |
| 12 |
|
| 13 |
Install gunicorn by running ``python -m pip install gunicorn``. For more |
| 14 |
details, see the `gunicorn documentation`_. |
| 15 |
|
| 16 |
.. _gunicorn documentation: https://docs.gunicorn.org/en/latest/install.html |
| 17 |
|
| 18 |
Running Django in Gunicorn as a generic WSGI application |
| 19 |
======================================================== |
| 20 |
|
| 21 |
When Gunicorn is installed, a ``gunicorn`` command is available which starts |
| 22 |
the Gunicorn server process. The simplest invocation of gunicorn is to pass the |
| 23 |
location of a module containing a WSGI application object named |
| 24 |
``application``, which for a typical Django project would look like: |
| 25 |
|
| 26 |
.. code-block:: shell |
| 27 |
|
| 28 |
gunicorn myproject.wsgi |
| 29 |
|
| 30 |
This will start one process running one thread listening on ``127.0.0.1:8000``. |
| 31 |
It requires that your project be on the Python path; the simplest way to ensure |
| 32 |
that is to run this command from the same directory as your ``manage.py`` file. |
| 33 |
|
| 34 |
See Gunicorn's `deployment documentation`_ for additional tips. |
| 35 |
|
| 36 |
.. _deployment documentation: https://docs.gunicorn.org/en/latest/deploy.html |