Looking to place your advertisement?

Advertise your brand and services to thousands of IT enthusiasts!

Install and configure Nginx on Ubuntu

  • avatar
  • 1 Like
  • 5 mins read

Nginx is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability. In addition to its HTTP server capabilities, Nginx can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers.

Installing Nginx

Nginx is available and can be installed using the apt packaging system:

sudo apt-get update && sudo apt-get install nginx

Package manager will install the server and all the dependencies. You can point your browser to your server IP address (or localhost). You should see this page:


Configure the Firewall

For additional security some settings must be applied to the firewall software to allow access to the service. Nginx is automatically registered as a service with ufw upon installation making it easy to allow Nginx access.

You can list available configurations with the following command:

sudo ufw app list

You should get a listing of the application profiles:


There are three profiles available for Nginx:

  • Nginx Full: this profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)

  • Nginx HTTP: this profile opens only port 80 (normal, unencrypted web traffic)

  • Nginx HTTPS: this profile opens only port 443 (TLS/SSL encrypted traffic)

In our case we select the FULL profile and allow traffic on ports 80 and 443:

sudo ufw allow 'Nginx Full'


Enable ufw and verify the change by typing:

sudo ufw enable && ufw status


Managing the Nginx Process

Now that you have your web server up and running you can use the following commands to manage the nginx process:

sudo systemctl [stop|start|restart|reload|disable|enable] nginx

Files and directories

We already have the web server but... where do we upload the files? The structure of the files is clear:


  • /var/www/html: The actual web content, which by default only consists of the default Nginx page.


  • /etc/nginx: The Nginx configuration directory. All of the Nginx configuration files are here.

  • /etc/nginx/nginx.conf: The main Nginx configuration file. This can be modified to make changes to the Nginx global configuration.

  • /etc/nginx/sites-available/: directory where separated site settings can be saved.

  • /etc/nginx/sites-enabled/: directory where we link one of the previous configurations and also mark them as active.


  • /var/log/nginx/access.log: every request to the web server is recorded in this log file.

  • /var/log/nginx/error.log: all Nginx errors will be recorded in this log.

 Join Our Monthly Newsletter

Get the latest news and popular articles to your inbox every month


Leave a Reply

Your email address will not be published.

Replying to message:

Hey visitor! Unlock access to featured articles, remove ads and much more - it's free.