← 返回命令列表

Linux command

uwsgi 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Run a WSGI application

uwsgi --http :8080 --wsgi-file [app.py]

Run with multiple processes and threads

uwsgi --http :8080 --wsgi-file [app.py] --master --processes [4] --threads [2]

Run with a Unix socket

uwsgi --socket [/tmp/uwsgi.sock] --wsgi-file [app.py] --chmod-socket=666

Run a Django application

uwsgi --http :8080 --module [myproject.wsgi]:application

Run from a configuration file

uwsgi --ini [uwsgi.ini]

Enable stats server

uwsgi --http :8080 --wsgi-file [app.py] --stats 127.0.0.1:9191

说明

uWSGI is an application server that implements the WSGI specification for serving Python web applications. It provides a bridge between web servers like Nginx and Python frameworks like Django, Flask, and Pyramid. The server supports multiple protocols: HTTP for direct serving, the uwsgi binary protocol for efficient Nginx communication, and sockets for local IPC. It handles process management, load balancing, and caching. Configuration can be provided via command-line options or INI/YAML/JSON files. The master process mode enables graceful reloading and automatic worker respawning.

参数

--http _address_
Enable HTTP server on specified address:port
--socket _address_
Bind to specified UNIX/TCP socket for uwsgi protocol
--wsgi-file _file_
Load WSGI application from Python file
--module _module_
Load WSGI application from specified module
--master
Enable master process for managing workers
--processes _n_
Spawn n worker processes
--threads _n_
Run n threads per worker process
--chdir _path_
Change to directory before loading application
--virtualenv _path_
Use specified Python virtualenv
--ini _file_
Load configuration from INI file
--stats _address_
Enable stats server on specified address
--chmod-socket
Set socket file permissions

FAQ

What is the uwsgi command used for?

uWSGI is an application server that implements the WSGI specification for serving Python web applications. It provides a bridge between web servers like Nginx and Python frameworks like Django, Flask, and Pyramid. The server supports multiple protocols: HTTP for direct serving, the uwsgi binary protocol for efficient Nginx communication, and sockets for local IPC. It handles process management, load balancing, and caching. Configuration can be provided via command-line options or INI/YAML/JSON files. The master process mode enables graceful reloading and automatic worker respawning.

How do I run a basic uwsgi example?

Run `uwsgi --http :8080 --wsgi-file [app.py]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --http _address_ do in uwsgi?

Enable HTTP server on specified address:port