Skip to main content

Nginx HTTP Server Installation

This guide covers the essential steps to install and start Nginx on Debian/Ubuntu and CentOS systems.


Installation Steps​

1. Update Package Index​

sudo apt update

2. Install Nginx​

sudo apt install nginx -y

3. Start and Enable Nginx​

sudo systemctl start nginx
sudo systemctl enable nginx

4. Check Status​

sudo systemctl status nginx

5. Allow HTTP/HTTPS in Firewall (if UFW is enabled)​

sudo ufw allow 'Nginx Full'

6. Test in Browser​

Visit: http://localhost or your server's IP address.


Uninstall Nginx​

sudo apt remove --purge nginx nginx-common -y
sudo apt autoremove -y

Quick Commands Reference​

TaskCommand
Start Nginxsudo systemctl start nginx
Stop Nginxsudo systemctl stop nginx
Restart Nginxsudo systemctl restart nginx
Enable on Bootsudo systemctl enable nginx
Statussudo systemctl status nginx
Test Configsudo nginx -t

Tip: Default web root is /var/www/html.