Skip to content

How to Install NGINX on Ubuntu

NGINX · Self-help guide

Installing NGINX on Ubuntu is usually quick, but it is important to do it in the right order so the service starts cleanly and can accept web traffic. This guide assumes you have SSH access to your VPS and permission to run commands with sudo or as root.

Step 1: Update the package list. Run:

sudo apt update

This refreshes Ubuntu’s software index so your server knows which package versions are available.

Step 2: Install NGINX:

sudo apt install nginx -y

Once complete, Ubuntu normally starts the NGINX service automatically.

Step 3: Check the service status:

sudo systemctl status nginx

You want to see active running. If it is not running, start it with:

sudo systemctl start nginx

Step 4: Enable NGINX to start after reboot:

sudo systemctl enable nginx

Step 5: Allow web traffic through the firewall. If you use UFW, run:

sudo ufw allow ‘Nginx Full’

This opens HTTP and HTTPS traffic. You can check firewall status with:

sudo ufw status

Step 6: Visit your server IP address in a browser. You should see the default NGINX welcome page. That confirms NGINX is installed and responding publicly.

Before adding a real website, always test the configuration:

sudo nginx -t

If the test passes, you can reload NGINX safely:

sudo systemctl reload nginx

Best practice is to create a separate server block for every website instead of editing the default file heavily. This keeps your hosting environment cleaner and makes troubleshooting much easier later.

Did this solve it?If not, Penny and the support team are ready to help.Start live chatOpen a ticket