How to Install Nginx on Ubuntu 26.04
Nginx (pronounced “engine x”) is an open-source, high-performance HTTP and reverse proxy server used by some of the largest sites on the Internet. It can act as a standalone web server, load balancer, content cache, and proxy for HTTP and non-HTTP services.
This guide explains how to install Nginx on Ubuntu 26.04, configure the firewall, and manage the service.
Prerequisites
Before continuing, make sure you are logged in as a user with sudo privileges , and that no other service such as Apache is running on port 80 or 443.
Installing Nginx
Nginx is available in the default Ubuntu repositories. To install it, run:
sudo apt update
sudo apt install nginxOnce the installation is completed, the Nginx service starts automatically. To verify it is running:
sudo systemctl status nginx● 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 Fri 2026-04-25 15:00:00 UTC; 10s ago
...
Nginx is now installed and running. You can manage the Nginx service in the same way as any other systemd unit.
Configuring the Firewall
Now that Nginx is running, you need to make sure the firewall allows traffic on HTTP (80) and HTTPS (443). If you are using ufw
, enable the Nginx Full profile which covers both ports:
sudo ufw allow 'Nginx Full'To verify the firewall status:
sudo ufw statusStatus: active
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
Nginx Full ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
Testing the Installation
To confirm Nginx is serving requests, open http://YOUR_IP in a browser. You should see the default Nginx welcome page. You can also test from the command line:
curl -I http://localhostHTTP/1.1 200 OK
Server: nginx/1.28.1 (Ubuntu)
...
Nginx Configuration Structure
- All Nginx configuration files are located in
/etc/nginx/. - The main configuration file is
/etc/nginx/nginx.conf. - Create a separate configuration file for each domain to keep things manageable. Server block files are stored in
/etc/nginx/sites-available/and must be symlinked to/etc/nginx/sites-enabled/to be active. - Follow the standard naming convention: if your domain is
mydomain.com, name the file/etc/nginx/sites-available/mydomain.com.conf. - The
/etc/nginx/snippets/directory holds reusable configuration fragments that can be included in server block files. - Log files (
access.loganderror.log) are located in/var/log/nginx/. Use a separate log file per server block. - Common document root locations:
/var/www/<site_name>,/var/www/html/<site_name>, or/home/<user>/<site_name>.
Conclusion
Nginx is now installed and ready to serve your applications on Ubuntu 26.04. To set up multiple sites on the same server, see the guide on Nginx server blocks .
![]()