How To

Install Nginx on Ubuntu 16.04: UFW, PPA, and Config Structure

Nginx (pronounced “engine x”) is a free, open-source, high-performance HTTP server and reverse proxy. It handles a large number of concurrent connections with a smaller memory footprint per connection compared to Apache, making it a reliable foundation for web applications and APIs.

This guide covers two methods to install Nginx on Ubuntu 16.04: from the default Ubuntu repositories, which is the simpler option, and from the official Nginx stable PPA, which provides the latest release. We also cover UFW firewall setup, systemctl service commands, and the Nginx directory layout.

Prerequisite: You need sudo access. Make sure no other service is running on port 80 or 443 before starting.

Install Nginx on Ubuntu 16.04: Repos, UFW, and Verification

Install Nginx from the Ubuntu 16.04 default repositories:

bashsudo apt updatesudo apt install nginx

The Nginx service starts automatically after installation. Verify it is running:

bashsudo systemctl status nginx

Check the installed version:

bashsudo nginx -v

The Ubuntu 16.04 default repositories provide Nginx 1.10.3.

Open the firewall. The Nginx Full UFW profile opens both HTTP (port 80) and HTTPS (port 443) in one command:

bashsudo ufw allow 'Nginx Full'

Run sudo ufw status to verify. Visit http://YOUR_SERVER_IP in a browser. The default Nginx welcome page confirms the server is installed and reachable.

Install the Latest Nginx from the Nginx PPA Repository

The Ubuntu 16.04 default repositories often lag behind the current Nginx stable release. If you need the latest version, add the official Nginx stable PPA, which is maintained directly by the Nginx project team. It gives you access to newer security patches, performance improvements, and HTTP/2 refinements that are not backported to the Ubuntu-packaged version.

Add the PPA and install Nginx:

bashsudo apt install software-properties-commonsudo add-apt-repository ppa:nginx/stablesudo apt updatesudo apt install nginx

Verify the installed version:

bashsudo nginx -v

The Nginx PPA version at the time of writing is 1.12.2, significantly more current than the 1.10.3 version in the Ubuntu repos. The PPA updates automatically when new Nginx stable releases are published, so future installs will always pull the latest.

Manage the Nginx Service and Understand the Config Layout

Control the Nginx service with standard systemctl commands:

bashsudo systemctl stop nginx      # Stop the servicesudo systemctl start nginx     # Start the servicesudo systemctl restart nginx   # Restart (briefly drops connections)sudo systemctl reload nginx    # Reload config without dropping connectionssudo systemctl disable nginx   # Disable auto-start at bootsudo systemctl enable nginx    # Enable auto-start at boot

Use reload after configuration changes. Reserve restart for cases where a full process restart is required, such as installing new Nginx modules.

Nginx config directory layout:

  • /etc/nginx/nginx.conf — main configuration file (global settings)
  • /etc/nginx/sites-available/ — server block configs for each domain (inactive until symlinked)
  • /etc/nginx/sites-enabled/ — symlinks to active server block files
  • /etc/nginx/snippets/ — reusable config fragments for SSL or other shared settings
  • /var/log/nginx/access.log and error.log (create a separate pair per domain)

Common document root locations: /var/www/example.com/home/user/example.com, and /opt/example.com.

Nginx is now installed and running on your Ubuntu 16.04 server. To enable HTTPS, follow the guide on securing Nginx with a free Let’s Encrypt SSL certificate. Leave a comment below if you run into any issues.

Cyber Defence

Recent Posts

Install Nginx on Ubuntu 18.04: UFW, Service Control, and Config

Nginx (pronounced "engine x") is a free, open-source, high-performance HTTP server and reverse proxy. It handles…

47 minutes ago

Secure Nginx with Let’s Encrypt on Ubuntu 18.04: SSL Setup Guide

Let's Encrypt is a free, automated, and open certificate authority run by the Internet Security Research…

50 minutes ago

Install PHP on Ubuntu 18.04: Apache, Nginx FPM, and Ondrej PPA

PHP is the most widely used server-side scripting language for web development. Ubuntu 18.04 ships with PHP…

54 minutes ago

Install Skype on Ubuntu 18.04: .deb Package and Auto-Updates

Skype is one of the most widely used communication platforms in the world. It lets you…

60 minutes ago

Install Samba on Ubuntu 18.04: Configure Shares and User Access

Samba is a free, open-source implementation of the SMB/CIFS network protocol that lets Linux servers share…

22 hours ago

Set Up an OpenVPN Server on Ubuntu 18.04 with EasyRSA and UFW

Running your own VPN gives you full control over your traffic, privacy, and connection security. It encrypts…

22 hours ago