How To Install Nginx on Ubuntu 20.04

07/10/2020Infrastructure,Nginx,UbuntuNginx,Ubuntu

Nginx is one of the most popular and highest performance web servers in the world.
In most cases it is used a web server or HTTP/HTTPS reverse proxy. Also recently it can become a proxy of UDP stream.

Install Nginx on Ubuntu 20.04

sudo apt update
sudo apt install nginx


Check If Your Nginx is Running

You can check Nginx status with the following command.

systemctl status nginx

Example:

$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2020-07-01 00:52:58 UTC; 15min ago
       Docs: man:nginx(8)
   Main PID: 2556 (nginx)
      Tasks: 3 (limit: 4637)
     Memory: 6.2M
     CGroup: /system.slice/nginx.service
             ├─2556 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ├─2557 nginx: worker process
             └─2558 nginx: worker process

Jul 01 00:52:58 ip-172-30-3-194 systemd[1]: Starting A high performance web server and a reverse>
Jul 01 00:52:58 ip-172-30-3-194 systemd[1]: Started A high performance web server and a reverse >
lines 1-14/14 (END)


Visit Your Nginx’s Website

Open your browser and visit your ubuntu with the URL “http:<Your server address>". If the screen like below is shown, your Nginx is running properly.

Because Nginx uses 80 port for http connection by default, you need to allow the port at your firewall.


Manage Your Nginx

You can start/stop with the following commands.

sudo systemctl start nginx
sudo systemctl stop nginx


Next Step >>