Skip to content
Myr

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 file

Take 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 back
1mod_wsgi
2========

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 3why, one step back
3

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 4–6why, one step back
4`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 back
7

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 8–9why, one step back
8* Tightly integrated with Apache httpd.
9* Supports Windows directly.

Merge branch '2.1.x'David Lordbefore adoption97298e0

line 10why, one step back
10* Requires a compiler and the Apache development headers to install.

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 11why, one step back
11* Does not require a reverse proxy setup.

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 12why, one step back
12

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 13–16why, one step back
13This page outlines the basics of running mod_wsgi-express, not the more
14complex 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 back
17

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 18–20why, one step back
18.. _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 back
21
22

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 23–24why, one step back
23Installing
24----------

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 25why, one step back
25

Merge branch '2.1.x'David Lordbefore adoption97298e0

lines 26–28why, one step back
26Installing mod_wsgi requires a compiler and the Apache server and
27development 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 back
29

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 30why, one step back
30Create a virtualenv, install your application, then install

Merge branch '2.1.x'David Lordbefore adoption97298e0

line 31why, one step back
31``mod_wsgi``.

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 32why, one step back
32

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 33why, one step back
33.. code-block:: text

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 34why, one step back
34

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 35why, one step back
35 $ cd hello-app

Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9

lines 36–37why, one step back
36 $ python -m venv .venv
37 $ . .venv/bin/activate

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 38–39why, one step back
38 $ pip install . # install your application
39 $ pip install mod_wsgi

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

lines 40–41why, one step back
40
41

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 42–43why, one step back
42Running
43-------

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 44why, one step back
44

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 45–48why, one step back
45The only argument to ``mod_wsgi-express`` specifies a script containing
46your 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 back
49

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 50–51why, one step back
50.. code-block:: python
51 :caption: ``wsgi.py``

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 52why, one step back
52

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 53why, one step back
53 from hello import app

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 54why, one step back
54

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 55why, one step back
55 application = app

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 56why, one step back
56

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 57–58why, one step back
57.. code-block:: python
58 :caption: ``wsgi.py``

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 59why, one step back
59

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 60why, one step back
60 from hello import create_app

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

lines 61–63why, one step back
61
62 application = create_app()63

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 64why, one step back
64Now 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 back
65

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 66why, one step back
66.. code-block:: text

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 67why, one step back
67

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 68why, one step back
68 $ mod_wsgi-express start-server wsgi.py --processes 4

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 69why, one step back
69

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 70–71why, one step back
70The ``--processes`` option specifies the number of worker processes to
71run; a starting value could be ``CPU * 2``.

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 72why, one step back
72

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 73–75why, one step back
73Logs 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 back
76
77

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 78–79why, one step back
78Binding Externally
79------------------

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 80why, one step back
80

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 81–84why, one step back
81Unlike the other WSGI servers in these docs, mod_wsgi can be run as
82root 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 back
85

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 86–88why, one step back
86For example, if you created a ``hello`` user and group, you should
87install 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 back
89

Merge branch '2.1.x'David Lordbefore adoption9139af1

line 90why, one step back
90.. code-block:: text

Merge pull request #4189 from mgu/feat/use-exclude-patterns-reloaderDavid Lordbefore adoption48ee204

line 91why, one step back
91

Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9

line 92why, one step back
92 $ sudo /home/hello/.venv/bin/mod_wsgi-express start-server \

Merge branch '2.1.x'David Lordbefore adoption9139af1

lines 93–94why, one step back
93 /home/hello/wsgi.py \
94 --user hello --group hello --port 80 --processes 4