uWSGI is an open-source, fast, and self-healing application server container that serves as a full stack for building hosting services. It is primarily known for efficiently running Python WSGI applications but supports various other languages and protocols (like Ruby/Rack, Perl/PSGI, PHP, Go) through its pluggable architecture. The current stable version is 2.0.31. The project has been in maintenance mode since October 2022, focusing on stability rather than new features.
pip install uwsgiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic WSGI 'Hello World' application and run it using the `uwsgi` command-line tool. The `--http` option binds to an HTTP port, `--wsgi-file` specifies your application file, `--callable` points to the WSGI callable, and `--processes`/`--threads` configure concurrency.
Ensure `build-essential` (Debian/Ubuntu) or `Development Tools` (Fedora/RHEL) and `python-dev`/`python-devel` are installed on your system. Alternatively, consider using `pyuwsgi` which provides pre-built wheels and includes common libraries.
Enable Python threads by adding `--enable-threads` (command line) or `enable-threads = true` (configuration file) to your uWSGI configuration. Running in multithreading mode (with `threads` option) automatically enables it.
Always place a reverse proxy (like Nginx or Apache) in front of uWSGI instances to sanitize/validate requests and proxy them using the `uwsgi` protocol.
Ensure your WSGI application or framework fully reads the request `wsgi.input` stream when a request body is expected.
Set appropriate permissions for the UNIX socket using the `--chmod-socket` option (e.g., `--chmod-socket=666` or specific user/group permissions) so your web server can access it.
Increase the buffer size with the `--buffer-size` option (e.g., `--buffer-size 8192`) up to 65535 bytes, based on your application's needs.
Start uWSGI as `root` if necessary for binding to privileged ports, but immediately drop privileges to a non-root user and group using the `uid` and `gid` options.