How to Install and Configure Nginx on Ubuntu 20.04

Nginx (pronounced as “Engine-X”) is an open source and lightweight web server that is often used as reverse proxy or HTTP cache. Nginx is a web server that can be used as a reverse proxy. It’s one of the most popular web servers in the world.

This article will show you how to install an Nginx on your linux virtual private server (VPS) and later will explore how to set up your own reverse proxy or web server in Ubuntu 20.04 LTS.

1) Install nginx :

$ sudo apt -y install nginx

2) Basic Nginx configuration :

linodelinux@ubuntu20:~$ sudo vi /etc/nginx/sites-available/default

Add the following under “server_name” :

How to Install and Configure Nginx on Ubuntu 20.04

3) Check syntax :

linodelinux@ubuntu20:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

4) Restart nginx service :

linodelinux@ubuntu20:~$ sudo systemctl restart nginx

5) Make nginx auto start at boot :

linodelinux@ubuntu20:~$ sudo systemctl enable nginx
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx

6) Test if nginx can be access at url http://test2.local
How to Install and Configure Nginx on Ubuntu 20.04

Leave a Comment