Install and set up Nginx on Ubuntu server
Learn how to install and configure Nginx on your Ubuntu server.
Update System Packages
First, let’s update the database of available packages versions.
sudo apt update
Install Nginx
Install nginx with the following command:
sudo apt install nginx -y
Check The installation
nginx -v
you should see the version of nginx installed, for example:
nginx version: nginx/1.24.0 (Ubuntu)
Adjust Firewall Settings
Depending on your previous firewall configuration, you may need to allow nginx in the firewall, nginx already registers it self as a service with ufw on installation, making it easy for us to allow it through the firewall.
sudo ufw allow 'Nginx Full'
sudo ufw allow 'Nginx HTTP'
sudo ufw allow 'Nginx HTTPS'
You can check the status of the firewall with:
sudo ufw status
In the output you should see the nginx profile you allowed, for example:
Status: active
To Action From
-- ------ ----
Nginx Full ALLOW Anywhere
Check Nginx Service Status
Nginx should be running after the installation, you can check it’s status at any time with:
sudo systemctl status nginx
You should see an output similar to this:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
Active: active (running) since Wed 2026-06-24 06:35:18 CEST; 1 week 2 days ago
Docs: man:nginx(8)
Process: 2571583 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 2571585 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 2571642 (nginx)
Tasks: 33 (limit: 153527)
Memory: 60.3M (peak: 65.1M)
CPU: 23.695s
Check Nginx is Serving Content
Nginx serves a default page on installation, you can check that by visiting your server’s IP address in a web browser:
http://your-server-ip
If you see the nginx default page, your nginx is installed and configured correctly, you are ready to start hosting your website/webservice on your server.
Managing Nginx Service
Like all other services managed by systemd, you can start, stop, restart, and reload the nginx service with the following commands:
To stop the nginx service:
sudo systemctl stop nginx
To start the nginx service:
sudo systemctl start nginx
To restart the nginx service:
sudo systemctl restart nginx
To reload the nginx service (without downtime):
sudo systemctl reload nginx
The reload command will reload the configuration files without stoping the service,very useful when you change configurations and do not want to cause downtime on all services served by nginx.
To stop nginx from running on boot, you can disable it with:
sudo systemctl disable nginx
To make nginx start on boot, you can enable it with:
sudo systemctl enable nginx
Next Steps
- Configuring Server blocks (Soon)
- Configuring SSL with Let’s Encrypt (Soon)
- Hardening Nginx (Soon)
- Performance Tuning Nginx (Soon)

