Nginx is a high-performance web server and reverse proxy widely used in production. This guide installs and configures Nginx on Ubuntu 24.04 LTS and enables it to serve content over HTTP.

Tested and valid on:

  • Ubuntu 24.04 LTS

Prerequisites

  • Ubuntu 24.04 LTS server
  • A user with sudo privileges
  • UFW firewall configured

Step 1 – Update Package Lists

Refresh your package index:

sudo apt update

Step 2 – Install Nginx

Install from the Ubuntu repository:

sudo apt install nginx -y

Step 3 – Allow Nginx Through UFW

Permit HTTP and HTTPS traffic:

sudo ufw allow 'Nginx Full'
sudo ufw status

Step 4 – Start and Enable Nginx

Start the service and configure it to start on boot:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 5 – Verify Nginx Is Running

Check the service status:

sudo systemctl status nginx

Visit http://your_server_ip in a browser — you should see the Nginx welcome page.

Step 6 – Explore the Directory Structure

Key Nginx paths on Ubuntu 24.04:

  • /etc/nginx/nginx.conf — main configuration
  • /etc/nginx/sites-available/ — virtual host definitions
  • /etc/nginx/sites-enabled/ — symlinks to active sites
  • /var/www/html/ — default document root
  • /var/log/nginx/ — access and error logs

Step 7 – Manage the Nginx Service

Common service management commands:

sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx   # reload config without dropping connections

Step 8 – Test the Configuration

Always test before reloading:

sudo nginx -t

Conclusion

Nginx is now installed and running on Ubuntu 24.04 LTS. The next step is to configure a server block for your domain and set up SSL with Let’s Encrypt — both covered in later tutorials in this series.