<h1>uWSGI<aclass="headerlink"href="#uwsgi"title="Link to this heading">¶</a></h1>
<p><aclass="reference external"href="https://uwsgi-docs.readthedocs.io/en/latest/">uWSGI</a> is a fast, compiled server suite with extensive configuration
and capabilities beyond a basic server.</p>
<ulclass="simple">
<li><p>It can be very performant due to being a compiled program.</p></li>
<li><p>It is complex to configure beyond the basic application, and has so
many options that it can be difficult for beginners to understand.</p></li>
<li><p>It does not support Windows (but does run on WSL).</p></li>
<li><p>It requires a compiler to install in some cases.</p></li>
</ul>
<p>This page outlines the basics of running uWSGI. Be sure to read its
documentation to understand what features are available.</p>
<sectionid="installing">
<h2>Installing<aclass="headerlink"href="#installing"title="Link to this heading">¶</a></h2>
<p>uWSGI has multiple ways to install it. The most straightforward is to
install the <codeclass="docutils literal notranslate"><spanclass="pre">pyuwsgi</span></code> package, which provides precompiled wheels for
common platforms. However, it does not provide SSL support, which can be
provided with a reverse proxy instead.</p>
<p>Create a virtualenv, install your application, then install <codeclass="docutils literal notranslate"><spanclass="pre">pyuwsgi</span></code>.</p>
<divclass="highlight-text notranslate"><divclass="highlight"><pre><span></span>$ cd hello-app
$ python -m venv .venv
$ . .venv/bin/activate
$ pip install . # install your application
$ pip install pyuwsgi
</pre></div>
</div>
<p>If you have a compiler available, you can install the <codeclass="docutils literal notranslate"><spanclass="pre">uwsgi</span></code> package
instead. Or install the <codeclass="docutils literal notranslate"><spanclass="pre">pyuwsgi</span></code> package from sdist instead of wheel.
<divclass="code-block-caption"><spanclass="caption-text"><codeclass="docutils literal notranslate"><spanclass="pre">wsgi.py</span></code></span><aclass="headerlink"href="#id2"title="Link to this code">¶</a></div>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">--http</span></code> option starts an HTTP server at 127.0.0.1 port 8000. The
<codeclass="docutils literal notranslate"><spanclass="pre">--master</span></code> option specifies the standard worker manager. The <codeclass="docutils literal notranslate"><spanclass="pre">-p</span></code>
option starts 4 worker processes; a starting value could be <codeclass="docutils literal notranslate"><spanclass="pre">CPU</span><spanclass="pre">*</span><spanclass="pre">2</span></code>.
The <codeclass="docutils literal notranslate"><spanclass="pre">-w</span></code> option tells uWSGI how to import your application</p>
</section>
<sectionid="binding-externally">
<h2>Binding Externally<aclass="headerlink"href="#binding-externally"title="Link to this heading">¶</a></h2>
<p>uWSGI should not be run as root with the configuration shown in this doc
because it would cause your application code to run as root, which is
not secure. However, this means it will not be possible to bind to port
80 or 443. Instead, a reverse proxy such as <aclass="reference internal"href="nginx.html"><spanclass="doc">nginx</span></a> or
<aclass="reference internal"href="apache-httpd.html"><spanclass="doc">Apache httpd</span></a> should be used in front of uWSGI. It is possible to
run uWSGI as root securely, but that is beyond the scope of this doc.</p>
<p>uWSGI has optimized integration with <aclass="reference external"href="https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html">Nginx uWSGI</a> and
<aclass="reference external"href="https://uwsgi-docs.readthedocs.io/en/latest/Apache.html#mod-proxy-uwsgi">Apache mod_proxy_uwsgi</a>, and possibly other servers, instead of using
a standard HTTP proxy. That configuration is beyond the scope of this
doc, see the links for more information.</p>
<p>You can bind to all external IPs on a non-privileged port using the
<codeclass="docutils literal notranslate"><spanclass="pre">--http</span><spanclass="pre">0.0.0.0:8000</span></code> option. Don’t do this when using a reverse proxy
setup, otherwise it will be possible to bypass the proxy.</p>