01 Overview
Nginx serves static files, terminates TLS, and reverse-proxies traffic to application backends with low memory overhead. It's the default front door for a large share of production web infrastructure and Kubernetes ingress controllers.
→ official documentation02 Installation
Pick a platform. Each step is copy-pasteable on its own.
01 Update package index
sudo apt update
02 Install Nginx
sudo apt install -y nginx
03 Enable and start the service
sudo systemctl enable --now nginx
04 Allow HTTP/HTTPS through the firewall
sudo ufw allow 'Nginx Full'
01 Install Nginx
sudo dnf install -y nginx
02 Enable and start the service
sudo systemctl enable --now nginx
03 Open the firewall
sudo firewall-cmd --permanent --add-service=http --add-service=https sudo firewall-cmd --reload
01 Install via Homebrew
brew install nginx
02 Start the service
brew services start nginx
Note — commands assume sudo privileges and an up-to-date package index. Pin a specific version in production rather than tracking latest.
03 Install script
The steps above bundled into a single idempotent shell script for provisioning boxes unattended.
install-nginx.sh
Ubuntu/Debian target · safe to re-run · exits non-zero on failure
04 Cheatsheet
The commands reached for most often once Nginx is installed.
| Command | What it does |
|---|---|
| sudo nginx -t | Test config syntax before reloading |
| sudo systemctl reload nginx | Reload config without dropping connections |
| sudo systemctl status nginx | Check service status |
| tail -f /var/log/nginx/access.log | Follow access logs |
| tail -f /var/log/nginx/error.log | Follow error logs |
| nginx -V | Show compiled-in modules and build flags |
| proxy_pass http://backend; | Forward requests to an upstream in a server block |