mod_wsgi.rst
This file
Path
docs/deploying/mod_wsgi.rst
94 lines · 2.7 KiB
Last changed by
Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
History of this fileTake it
The walk stopped after 200 commits: lines older than 48ee204 point at it.
Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 1–2why, one step back1mod_wsgi2========Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 3why, one step back3Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 4–6why, one step back4`mod_wsgi`_ is a WSGI server integrated with the `Apache httpd`_ server.5The modern `mod_wsgi-express`_ command makes it easy to configure and6start the server without needing to write Apache httpd configuration.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 7why, one step back7Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 8–9why, one step back8* Tightly integrated with Apache httpd.9* Supports Windows directly.Merge branch '2.1.x'David Lordbefore adoption97298e0
line 10why, one step back10* Requires a compiler and the Apache development headers to install.Merge branch '2.1.x'David Lordbefore adoption9139af1
line 11why, one step back11* Does not require a reverse proxy setup.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 12why, one step back12Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 13–16why, one step back13This page outlines the basics of running mod_wsgi-express, not the more14complex installation and configuration with httpd. Be sure to read the15`mod_wsgi-express`_, `mod_wsgi`_, and `Apache httpd`_ documentation to16understand what features are available.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 17why, one step back17Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 18–20why, one step back18.. _mod_wsgi-express: https://pypi.org/project/mod-wsgi/19.. _mod_wsgi: https://modwsgi.readthedocs.io/20.. _Apache httpd: https://httpd.apache.org/Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
lines 21–22why, one step back2122Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 23–24why, one step back23Installing24----------Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 25why, one step back25Merge branch '2.1.x'David Lordbefore adoption97298e0
lines 26–28why, one step back26Installing mod_wsgi requires a compiler and the Apache server and27development headers installed. You will get an error if they are not.28How to install them depends on the OS and package manager that you use.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 29why, one step back29Merge branch '2.1.x'David Lordbefore adoption9139af1
line 30why, one step back30Create a virtualenv, install your application, then installMerge branch '2.1.x'David Lordbefore adoption97298e0
line 31why, one step back31``mod_wsgi``.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 32why, one step back32Merge branch '2.1.x'David Lordbefore adoption9139af1
line 33why, one step back33.. code-block:: textMerge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 34why, one step back34Merge branch '2.1.x'David Lordbefore adoption9139af1
line 35why, one step back35 $ cd hello-appMerge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
lines 36–37why, one step back36 $ python -m venv .venv37 $ . .venv/bin/activateMerge branch '2.1.x'David Lordbefore adoption9139af1
lines 38–39why, one step back38 $ pip install . # install your application39 $ pip install mod_wsgiMerge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
lines 40–41why, one step back4041Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 42–43why, one step back42Running43-------Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 44why, one step back44Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 45–48why, one step back45The only argument to ``mod_wsgi-express`` specifies a script containing46your Flask application, which must be called ``application``. You can47write a small script to import your app with this name, or to create it48if using the app factory pattern.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 49why, one step back49Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 50–51why, one step back50.. code-block:: python51 :caption: ``wsgi.py``Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 52why, one step back52Merge branch '2.1.x'David Lordbefore adoption9139af1
line 53why, one step back53 from hello import appMerge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 54why, one step back54Merge branch '2.1.x'David Lordbefore adoption9139af1
line 55why, one step back55 application = appMerge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 56why, one step back56Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 57–58why, one step back57.. code-block:: python58 :caption: ``wsgi.py``Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 59why, one step back59Merge branch '2.1.x'David Lordbefore adoption9139af1
line 60why, one step back60 from hello import create_appMerge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
lines 61–63why, one step back6162 application = create_app()63Merge branch '2.1.x'David Lordbefore adoption9139af1
line 64why, one step back64Now run the ``mod_wsgi-express start-server`` command.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 65why, one step back65Merge branch '2.1.x'David Lordbefore adoption9139af1
line 66why, one step back66.. code-block:: textMerge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 67why, one step back67Merge branch '2.1.x'David Lordbefore adoption9139af1
line 68why, one step back68 $ mod_wsgi-express start-server wsgi.py --processes 4Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 69why, one step back69Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 70–71why, one step back70The ``--processes`` option specifies the number of worker processes to71run; a starting value could be ``CPU * 2``.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 72why, one step back72Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 73–75why, one step back73Logs for each request aren't show in the terminal. If an error occurs,74its information is written to the error log file shown when starting the75server.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
lines 76–77why, one step back7677Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 78–79why, one step back78Binding Externally79------------------Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 80why, one step back80Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 81–84why, one step back81Unlike the other WSGI servers in these docs, mod_wsgi can be run as82root to bind to privileged ports like 80 and 443. However, it must be83configured to drop permissions to a different user and group for the84worker processes.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 85why, one step back85Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 86–88why, one step back86For example, if you created a ``hello`` user and group, you should87install your virtualenv and application as that user, then tell88mod_wsgi to drop to that user after starting.Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 89why, one step back89Merge branch '2.1.x'David Lordbefore adoption9139af1
line 90why, one step back90.. code-block:: textMerge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204
line 91why, one step back91Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
line 92why, one step back92 $ sudo /home/hello/.venv/bin/mod_wsgi-express start-server \Merge branch '2.1.x'David Lordbefore adoption9139af1
lines 93–94why, one step back93 /home/hello/wsgi.py \94 --user hello --group hello --port 80 --processes 4