# Nginx Unit — Dynamic Polyglot Application Server > A lightweight application server by the Nginx team that runs Go, Python, Node.js, Java, Perl, PHP, Ruby, and WebAssembly apps behind a RESTful JSON API for zero-downtime configuration. ## Install Save as a script file and run: # Nginx Unit — Dynamic Polyglot Application Server ## Quick Use ```bash # Install on Ubuntu/Debian curl --output /usr/share/keyrings/nginx-keyring.gpg https://unit.nginx.org/keys/nginx-keyring.gpg apt install unit unit-python3.11 unit-php # Start a Python app via the config API curl -X PUT --data-binary @config.json --unix-socket /var/run/control.unit.sock http://localhost/config ``` ## Introduction Nginx Unit is an application server built by the Nginx core team that can run applications in multiple languages simultaneously. Configuration is managed through a RESTful JSON API, allowing you to add routes, change listeners, and deploy new app versions without restarts or dropped connections. ## What Nginx Unit Does - Serves applications written in Python, PHP, Go, Node.js, Java, Ruby, Perl, and WebAssembly - Provides a RESTful JSON API for runtime configuration without server restarts - Routes requests by URI, host, method, headers, and other properties - Handles TLS termination with automatic certificate management - Serves static files alongside dynamic applications in a single server ## Architecture Overview Unit uses a multi-process architecture with a controller process that owns the config API and router processes that handle incoming connections. Each application language runs in isolated worker processes managed by language-specific modules. Configuration changes are applied atomically: the controller validates the new config, forks new workers, drains old ones, and swaps routing tables with zero downtime. ## Self-Hosting & Configuration - Install from the official repository for your OS or run the Docker image `docker run -d unit` - Send JSON configuration to the control socket at `/var/run/control.unit.sock` - Define listeners, routes, and applications in a single JSON document - Update any subtree of the config with PUT, PATCH, or DELETE requests - TLS certificates are uploaded as PEM bundles via the `/certificates` API endpoint ## Key Features - Zero-downtime configuration: changes apply without connection drops - Per-application process isolation with configurable worker counts - Built-in request routing with pattern matching and header-based rules - Static file serving with MIME type detection and directory listings - Native WebAssembly support via the Wasm component model ## Comparison with Similar Tools - **Nginx** — reverse proxy and static server; Unit adds native multi-language app serving with a config API - **Apache** — venerable multi-module server; Unit offers simpler dynamic configuration and polyglot support - **Gunicorn** — Python-only WSGI server; Unit handles multiple languages in one process tree - **Caddy** — automatic HTTPS reverse proxy; Unit focuses on application serving rather than proxying ## FAQ **Q: Can Unit replace Nginx as a reverse proxy?** A: Unit can proxy and serve apps, but Nginx remains stronger for complex proxy scenarios like load balancing pools and caching. They are often used together. **Q: How do I deploy a new app version without downtime?** A: PUT the updated application config to the API. Unit spins up new workers, waits for in-flight requests to finish on old workers, then shuts them down. **Q: Does Unit support HTTP/2?** A: Yes. HTTP/2 is supported on TLS listeners. HTTP/3 (QUIC) support is in development. **Q: What operating systems are supported?** A: Unit runs on Linux, FreeBSD, and macOS. Official packages are available for major Linux distributions. Docker images are also provided. ## Sources - https://github.com/nginx/unit - https://unit.nginx.org/ --- Source: https://tokrepo.com/en/workflows/asset-408c00ee Author: Script Depot