SlideShare a Scribd company logo
1 of 10
Download to read offline
INSTALL NGINX
ON UBUNTU
21.04 SERVER
Nginx is open-source, high-
performance Web server.
Prepared by: Satish Kumar
Founder, LinuxConcept
LINUXCONCEPT
LINUXCONCEPT
LINUXCONCEPT
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
LINUXCONCEPT
Nginx is the most potent, open-source, and a high-
performance Web server. It can work as a reverse proxy
server also, nowadays, is used by most of the most
significant websites on the internet.
People pronounced “engine x” for Nginx; it is the hot
choice for every website owner to power their site with
Nginx.
In comparison to the Apache web server, Nginx is
capable of handling more connections with a few
amount of memory footprint in each connection.
Prerequisites
Make sure your Linux box does not have an Apache
HTTP server or any application service running on port
80 and 443. You should have sudo privileges to execute
commands on your Linux machine.
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
LINUXCONCEPT
INSTALL NGINX
Nowadays, Nginx software packages built-in Ubuntu default
software repository, so the installation is effortless, You just
run the following commands in terminal:
# sudo apt update
# sudo apt install nginx
After installation of Nginx, you can check the status of the
Nginx service by using the following command:
# sudo systemctl status nginx
The output of the above command should show that the Nginx
service is running:
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 Sun 2020-22-06 15:44:04
UTC; 1min 59s ago
Main PID: 1461 (nginx)
CGroup: /system.slice/nginx.service
├─1461 nginx: master process /usr/sbin/nginx -g
daemon on; master_process on
└─1463 nginx: worker process
You can also check the version of Nginx Web server, using the
following command:
# sudo nginx -v
nginx version: nginx/1.14.0 (Ubuntu)
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
LINUXCONCEPT
FIREWALL CONFIGURATION
Today, we all are using the UFW firewall to manage network
connection and traffic on the Ubuntu machine. To use Nginx,
you will need to open HTTP Port (80) and HTTPS port (443).
You can open HTTP and HTTPS port by enabling “Nginx Full”
profile on UFW:
# sudo ufw allow 'Nginx Full'
You can verify the firewall configuration using below
command:
# sudo ufw status
The output of the above command is something like below:
Status: active
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
Nginx Full ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
LINUXCONCEPT
Nginx Installation Test
You can verify that installed Nginx is working as expected by
opening in your browser with your IP (http://your-IP). You will get
the browser screen with default Nginx welcome page, as shown
below:
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
LINUXCONCEPT
Install Nginx using Nginx PPA Repository
The Ubuntu default software repository is not updating
packages regularly, so it often outdated. To install Nginx’s
latest version, use Nginx’s official PPA repository.
To install Nginx using PPA repository in Ubuntu 21.04, follow
below steps:
01. install “software-properties-common” in Ubuntu system
# sudo apt install software-properties-common
02. Add Nginx’s PPA repository using following command
# sudo add-apt-repository ppa:nginx/stable
03. Update package manager with list and install Nginx using
following command:
# sudo apt update
# sudo apt install nginx
04. After completing the installation of Nginx, check the
version of installed Nginx
# sudo nginx -v
nginx version: nginx/1.17.0
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
LINUXCONCEPT
Manage Nginx service with systemctl
You can manage Nginx services with the similar command what
use to manage other system services.
Start the Nginx Service:
# sudo systemctl start nginx
Stop the Nginx Service:
# sudo systemctl stop nginx
Restart the Nginx Service:
# sudo systemctl restart nginx
Reload the Nginx Service:
# sudo systemctl reload nginx
Enable the Nginx Service to start at boot:
# sudo systemctl enable nginx
Disable the Nginx Service to not start on boot:
# sudo systemctl disable nginx
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
LINUXCONCEPT
The Nginx configuration files will always remain in the
“/etc/nginx/” directory.
The main Nginx’s setting files located at
“/etc/nginx/nginx.conf.”
To keep Nginx configuration is simple by configuring
separate files for each site. You can keep as much as you
want with a configuration file with a server block.
Nginx server block files or site configuration files stored in
the “/etc/nginx/sites-available/” directory. To make these
files in use on Nginx, link the files in the “/etc/nginx/sites-
enable/” directory.
To activate any new site configuration, we need to create a
symlink of site configuration file available in the “sites-
available” directory to the “sites-enabled” directory.
To identify the site’s configuration, follow the standard
naming conversion for server block files. For example, you
have a site testweb.com. It is better to create a file as
“/etc/nginx/sites-available/testweb.com.conf” to identify
quickly when you have multiple sites configured in the Nginx
web server.
Nginx configuration file’s structure on Ubuntu
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
LINUXCONCEPT
/home/<user>/<site-name>
/var/www/<site-name>
/var/www/html/<site-name>
/opt/<site-name>
There is no boundry to configure domain document root
directory, you can set any location you want. But the most
recommended location for web root directory are:
Conclusion
Congratulation; now you have installed the Nginx Web server
on your Ubuntu 21.04 server. Now, you are ready to deploy
and run your application using Nginx as a web server or
reverse proxy server.
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
LINUXCONCEPT
THANK YOU
You can check our website https://linuxconcept.com for
more similar information on Linux or opensource
technologies.
https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/

More Related Content

Similar to Install nginx on ubuntu 21.04 server

Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8Kaan Aslandağ
 
Jfrog artifactory as private docker registry
Jfrog artifactory as private docker registryJfrog artifactory as private docker registry
Jfrog artifactory as private docker registryVipin Mandale
 
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...VEXXHOST Private Cloud
 
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web serverNginx 0.8.x + php 5.2.13 (fast cgi) setup web server
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web serverwruben
 
How to install Setup & Configure SSH Jump Server on a Linux box
How to install Setup & Configure  SSH Jump Server on a Linux boxHow to install Setup & Configure  SSH Jump Server on a Linux box
How to install Setup & Configure SSH Jump Server on a Linux boxEzee Login
 
NGINX Installation and Tuning
NGINX Installation and TuningNGINX Installation and Tuning
NGINX Installation and TuningNGINX, Inc.
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stackRootGate
 
How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7VCP Muthukrishna
 
Making Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixMaking Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixDiana Tkachenko
 
Multiple django applications on a single server with nginx
Multiple django applications on a single server with nginxMultiple django applications on a single server with nginx
Multiple django applications on a single server with nginxroskakori
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantBrian Hogan
 
VMWare VSphere4 Documentation Notes
VMWare VSphere4 Documentation NotesVMWare VSphere4 Documentation Notes
VMWare VSphere4 Documentation NotesGrit Suwa
 
APACHE
APACHEAPACHE
APACHEARJUN
 
NGiNX, VHOSTS & SSL (let's encrypt)
NGiNX, VHOSTS & SSL (let's encrypt)NGiNX, VHOSTS & SSL (let's encrypt)
NGiNX, VHOSTS & SSL (let's encrypt)Marcel Cattaneo
 
Стажировка 2015. Разработка. Занятие 5. Использование nginx
Стажировка 2015. Разработка. Занятие 5. Использование nginxСтажировка 2015. Разработка. Занятие 5. Использование nginx
Стажировка 2015. Разработка. Занятие 5. Использование nginx7bits
 

Similar to Install nginx on ubuntu 21.04 server (20)

Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8
 
Nginx
NginxNginx
Nginx
 
Installing lemp with ssl and varnish on Debian 9
Installing lemp with ssl and varnish on Debian 9Installing lemp with ssl and varnish on Debian 9
Installing lemp with ssl and varnish on Debian 9
 
Jfrog artifactory as private docker registry
Jfrog artifactory as private docker registryJfrog artifactory as private docker registry
Jfrog artifactory as private docker registry
 
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
How To Setup Highly Available Web Servers with Keepalived & Floating IPs on U...
 
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web serverNginx 0.8.x + php 5.2.13 (fast cgi) setup web server
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
 
How to install Setup & Configure SSH Jump Server on a Linux box
How to install Setup & Configure  SSH Jump Server on a Linux boxHow to install Setup & Configure  SSH Jump Server on a Linux box
How to install Setup & Configure SSH Jump Server on a Linux box
 
NGINX Installation and Tuning
NGINX Installation and TuningNGINX Installation and Tuning
NGINX Installation and Tuning
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stack
 
How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7
 
Making Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixMaking Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch Fix
 
Multiple django applications on a single server with nginx
Multiple django applications on a single server with nginxMultiple django applications on a single server with nginx
Multiple django applications on a single server with nginx
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
 
Its3 Drupal
Its3 DrupalIts3 Drupal
Its3 Drupal
 
VMWare VSphere4 Documentation Notes
VMWare VSphere4 Documentation NotesVMWare VSphere4 Documentation Notes
VMWare VSphere4 Documentation Notes
 
APACHE
APACHEAPACHE
APACHE
 
Its3 Drupal
Its3 DrupalIts3 Drupal
Its3 Drupal
 
NGiNX, VHOSTS & SSL (let's encrypt)
NGiNX, VHOSTS & SSL (let's encrypt)NGiNX, VHOSTS & SSL (let's encrypt)
NGiNX, VHOSTS & SSL (let's encrypt)
 
Стажировка 2015. Разработка. Занятие 5. Использование nginx
Стажировка 2015. Разработка. Занятие 5. Использование nginxСтажировка 2015. Разработка. Занятие 5. Использование nginx
Стажировка 2015. Разработка. Занятие 5. Использование nginx
 
Security Testing Using Infrastructure-As-Code
Security Testing Using Infrastructure-As-CodeSecurity Testing Using Infrastructure-As-Code
Security Testing Using Infrastructure-As-Code
 

Recently uploaded

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 

Recently uploaded (20)

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 

Install nginx on ubuntu 21.04 server

  • 1. INSTALL NGINX ON UBUNTU 21.04 SERVER Nginx is open-source, high- performance Web server. Prepared by: Satish Kumar Founder, LinuxConcept LINUXCONCEPT LINUXCONCEPT LINUXCONCEPT https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
  • 2. LINUXCONCEPT Nginx is the most potent, open-source, and a high- performance Web server. It can work as a reverse proxy server also, nowadays, is used by most of the most significant websites on the internet. People pronounced “engine x” for Nginx; it is the hot choice for every website owner to power their site with Nginx. In comparison to the Apache web server, Nginx is capable of handling more connections with a few amount of memory footprint in each connection. Prerequisites Make sure your Linux box does not have an Apache HTTP server or any application service running on port 80 and 443. You should have sudo privileges to execute commands on your Linux machine. https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
  • 3. LINUXCONCEPT INSTALL NGINX Nowadays, Nginx software packages built-in Ubuntu default software repository, so the installation is effortless, You just run the following commands in terminal: # sudo apt update # sudo apt install nginx After installation of Nginx, you can check the status of the Nginx service by using the following command: # sudo systemctl status nginx The output of the above command should show that the Nginx service is running: 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 Sun 2020-22-06 15:44:04 UTC; 1min 59s ago Main PID: 1461 (nginx) CGroup: /system.slice/nginx.service ├─1461 nginx: master process /usr/sbin/nginx -g daemon on; master_process on └─1463 nginx: worker process You can also check the version of Nginx Web server, using the following command: # sudo nginx -v nginx version: nginx/1.14.0 (Ubuntu) https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
  • 4. LINUXCONCEPT FIREWALL CONFIGURATION Today, we all are using the UFW firewall to manage network connection and traffic on the Ubuntu machine. To use Nginx, you will need to open HTTP Port (80) and HTTPS port (443). You can open HTTP and HTTPS port by enabling “Nginx Full” profile on UFW: # sudo ufw allow 'Nginx Full' You can verify the firewall configuration using below command: # sudo ufw status The output of the above command is something like below: Status: active To Action From -- ------ ---- 22/tcp ALLOW Anywhere Nginx Full ALLOW Anywhere 22/tcp (v6) ALLOW Anywhere (v6) Nginx Full (v6) ALLOW Anywhere (v6) https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
  • 5. LINUXCONCEPT Nginx Installation Test You can verify that installed Nginx is working as expected by opening in your browser with your IP (http://your-IP). You will get the browser screen with default Nginx welcome page, as shown below: https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
  • 6. LINUXCONCEPT Install Nginx using Nginx PPA Repository The Ubuntu default software repository is not updating packages regularly, so it often outdated. To install Nginx’s latest version, use Nginx’s official PPA repository. To install Nginx using PPA repository in Ubuntu 21.04, follow below steps: 01. install “software-properties-common” in Ubuntu system # sudo apt install software-properties-common 02. Add Nginx’s PPA repository using following command # sudo add-apt-repository ppa:nginx/stable 03. Update package manager with list and install Nginx using following command: # sudo apt update # sudo apt install nginx 04. After completing the installation of Nginx, check the version of installed Nginx # sudo nginx -v nginx version: nginx/1.17.0 https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
  • 7. LINUXCONCEPT Manage Nginx service with systemctl You can manage Nginx services with the similar command what use to manage other system services. Start the Nginx Service: # sudo systemctl start nginx Stop the Nginx Service: # sudo systemctl stop nginx Restart the Nginx Service: # sudo systemctl restart nginx Reload the Nginx Service: # sudo systemctl reload nginx Enable the Nginx Service to start at boot: # sudo systemctl enable nginx Disable the Nginx Service to not start on boot: # sudo systemctl disable nginx https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
  • 8. LINUXCONCEPT The Nginx configuration files will always remain in the “/etc/nginx/” directory. The main Nginx’s setting files located at “/etc/nginx/nginx.conf.” To keep Nginx configuration is simple by configuring separate files for each site. You can keep as much as you want with a configuration file with a server block. Nginx server block files or site configuration files stored in the “/etc/nginx/sites-available/” directory. To make these files in use on Nginx, link the files in the “/etc/nginx/sites- enable/” directory. To activate any new site configuration, we need to create a symlink of site configuration file available in the “sites- available” directory to the “sites-enabled” directory. To identify the site’s configuration, follow the standard naming conversion for server block files. For example, you have a site testweb.com. It is better to create a file as “/etc/nginx/sites-available/testweb.com.conf” to identify quickly when you have multiple sites configured in the Nginx web server. Nginx configuration file’s structure on Ubuntu https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
  • 9. LINUXCONCEPT /home/<user>/<site-name> /var/www/<site-name> /var/www/html/<site-name> /opt/<site-name> There is no boundry to configure domain document root directory, you can set any location you want. But the most recommended location for web root directory are: Conclusion Congratulation; now you have installed the Nginx Web server on your Ubuntu 21.04 server. Now, you are ready to deploy and run your application using Nginx as a web server or reverse proxy server. https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/
  • 10. LINUXCONCEPT THANK YOU You can check our website https://linuxconcept.com for more similar information on Linux or opensource technologies. https://linuxconcept.com/how-to-install-nginx-on-ubuntu-21-04-server/