Home » Django & REST Api » What is Nginx and how to install Nginx on Ubuntu 20.04 ?

What is Nginx and how to install Nginx on Ubuntu 20.04 ?

What is Nginx ?

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.

How to install Nginx on Ubuntu 20.04 ?

Installing Nginx on Ubuntu 20.04 is very simple, just type the below command and you are all set with the installation..

$ sudo apt-get install nginx

When you install nginx, the prerequisite packages as below will also be automatically get installed,

libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream nginx nginx-common nginx-core

by default, when you install nginx, the important configuration files are created at /etc/nginx

$ tree /etc/nginx/

/etc/nginx/
├── blocked_bots
├── blocked_ips
├── conf.d
├── fastcgi.conf
├── fastcgi_params
├── koi-utf
├── koi-win
├── mime.types
├── modules-available
├── modules-enabled
│   ├── 50-mod-http-image-filter.conf -> /usr/share/nginx/modules-available/mod-http-image-filter.conf
│   ├── 50-mod-http-xslt-filter.conf -> /usr/share/nginx/modules-available/mod-http-xslt-filter.conf
│   ├── 50-mod-mail.conf -> /usr/share/nginx/modules-available/mod-mail.conf
│   └── 50-mod-stream.conf -> /usr/share/nginx/modules-available/mod-stream.conf
├── nginx.conf
├── pagespeed.conf
├── proxy.conf
├── proxy_params
├── scgi_params
├── sites-available
│   └── default
├── sites-enabled
├── snippets
│   ├── fastcgi-php.conf
│   └── snakeoil.conf
├── ssl
│   └── dhparams.pem
├── uwsgi_params
└── win-utf

Now, when we tried to see the nginx status, by default it is showing as,

$ 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: inactive (dead)
       Docs: man:nginx(8)

Now, you needs to start the nginx server as,

$ sudo systemctl start nginx
$ 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 Fri 2021-02-05 01:13:36 IST; 2s ago
       Docs: man:nginx(8)
    Process: 10362 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 10374 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 10375 (nginx)
      Tasks: 9 (limit: 9324)
     Memory: 10.2M
     CGroup: /system.slice/nginx.service
             ├─10375 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ├─10376 nginx: worker process
             ├─10377 nginx: worker process
             ├─10378 nginx: worker process
             ├─10379 nginx: worker process
             ├─10380 nginx: worker process
             ├─10381 nginx: worker process
             ├─10382 nginx: worker process
             └─10383 nginx: worker process

Feb 05 01:13:36 devlab systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 05 01:13:36 devlab systemd[1]: Started A high performance web server and a reverse proxy server.

If required you can stop the nginx as,

$ sudo systemctl stop nginx

In our next post, Hosting a static website with Nginx on Ubuntu we will detail how you can host your first website with nginx.

How to install terraform on ubuntu ...
How to install terraform on ubuntu 20.04

Leave a Comment

Sign up to our newsletter!