What this is
This guide shows how to install and run Nginx on common Linux distributions.
What it is for
- Fast web server for static sites
- Reverse proxy for apps (Node/PHP-FPM/etc.)
Prerequisites
- SSH access + sudo
Steps by distribution
A) Ubuntu/Debian
sudo apt update
sudo apt install -y nginx
sudo systemctl enable --now nginx
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
B) CentOS/RHEL/Rocky/AlmaLinux
sudo dnf install -y nginx
sudo systemctl enable --now nginx
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --reload
Verification
sudo systemctl status nginx --no-pager
curl -I http://127.0.0.1
Warnings & notes
- If another web server is running (Apache), port 80 may be in use.
Conclusion
Nginx is installed and running. Next steps: server blocks (virtual hosts) and HTTPS.