How to Set Up Nginx Web Server
How to Set Up Nginx Web Server
Ubuntu / Debian
- Connect to your server via SSH Terminal or your local SSH client.
- Update packages and install Nginx:
apt update && apt upgrade -y apt install nginx -y - Start and enable Nginx to run on boot:
systemctl start nginx systemctl enable nginx - Verify Nginx is running:
systemctl status nginx - Allow HTTP and HTTPS traffic through the firewall:
ufw allow 'Nginx Full' ufw enable - Visit your server's IP address in a browser (e.g.,
http://YOUR_SERVER_IP). You should see the Nginx welcome page. - Place your website files in
/var/www/html/or create a new site configuration in/etc/nginx/sites-available/.
CentOS / AlmaLinux / Rocky Linux
dnf install nginx -y
systemctl start nginx
systemctl enable nginx
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload