2011-10-22 12:30:10 +08:00
|
|
|
===============================
|
|
|
|
How to use Django with Gunicorn
|
|
|
|
===============================
|
|
|
|
|
|
|
|
.. highlight:: bash
|
|
|
|
|
|
|
|
Gunicorn_ ('Green Unicorn') is a pure-Python WSGI server for UNIX. It has no
|
|
|
|
dependencies and is easy to install and use.
|
|
|
|
|
2018-09-26 14:48:47 +08:00
|
|
|
.. _Gunicorn: https://gunicorn.org/
|
2011-10-22 12:30:10 +08:00
|
|
|
|
|
|
|
Installing Gunicorn
|
|
|
|
===================
|
|
|
|
|
2014-09-22 01:58:44 +08:00
|
|
|
Installing gunicorn is as easy as ``pip install gunicorn``. For more
|
2012-03-03 17:11:54 +08:00
|
|
|
details, see the `gunicorn documentation`_.
|
2011-10-22 12:30:10 +08:00
|
|
|
|
2018-09-26 14:48:47 +08:00
|
|
|
.. _gunicorn documentation: https://docs.gunicorn.org/en/latest/install.html
|
2011-10-22 12:30:10 +08:00
|
|
|
|
|
|
|
Running Django in Gunicorn as a generic WSGI application
|
|
|
|
========================================================
|
|
|
|
|
|
|
|
When Gunicorn is installed, a ``gunicorn`` command is available which starts
|
|
|
|
the Gunicorn server process. At its simplest, gunicorn just needs to be called
|
2014-09-06 23:13:45 +08:00
|
|
|
with the location of a module containing a WSGI application object named
|
2014-09-06 07:41:47 +08:00
|
|
|
`application`. So for a typical Django project, invoking gunicorn would look
|
|
|
|
like::
|
2011-10-22 12:30:10 +08:00
|
|
|
|
2014-09-06 07:41:47 +08:00
|
|
|
gunicorn myproject.wsgi
|
2011-10-22 12:30:10 +08:00
|
|
|
|
2014-09-06 07:41:47 +08:00
|
|
|
This will start one process running one thread listening on ``127.0.0.1:8000``.
|
|
|
|
It requires that your project be on the Python path; the simplest way to ensure
|
|
|
|
that is to run this command from the same directory as your ``manage.py`` file.
|
2011-10-22 12:30:10 +08:00
|
|
|
|
2014-08-03 03:02:29 +08:00
|
|
|
See Gunicorn's `deployment documentation`_ for additional tips.
|
2011-10-22 12:30:10 +08:00
|
|
|
|
2018-09-26 14:48:47 +08:00
|
|
|
.. _deployment documentation: https://docs.gunicorn.org/en/latest/deploy.html
|