• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / nginx server tutorials (installation, configuration, performance tuning, security) / nginx installation on ubuntu 20.04 LTS

nginx installation on ubuntu 20.04 LTS

 

Note: Installation Process of ubuntu & debian almost same. but we have to choose distribution code.

also follow lemp installation process

 

Mainline or stable nginx (we choose mainline for latest features as well security updates)

stable only security updates (recommended long term deployments maybe)

 

Table of Contents

Toggle
  • Easy Method 1 : Installing Prebuilt Debian Packages
    • Check Nginx status
    • 2. Prebuilt Ubuntu Package from the Official NGINX Repository
      • Ubuntu
  • To set up the apt repository for stable nginx packages, run the following command:
  • If you would like to use mainline nginx packages, run the following command instead:
  • Upgrading Nginx to latest version ubuntu

Easy Method 1 : Installing Prebuilt Debian Packages

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

check nginx version

nginx -V

sudo nginx -v
nginx version: nginx/1.6.2

nginx version: nginx/1.18.0 (Ubuntu)    some old version form ubuntu repository if you wanr new go for below 2nd method

by the way nginx latest version from here (http://nginx.org/en/linux_packages.html)

Allow ufw firewall for nginx

  1. sudo ufw allow ‘Nginx HTTP’

Check Nginx status

systemctl status nginx

 

check your web server by IP Address

Next step:  configuring nginx by Nginx.conf nginx performance tuning

Installing Prebuilt Ubuntu Packages
NGINX provides packages for the following Ubuntu operating systems:

 

Version Codename Supported Platforms
16.04 xenial x86_64, i386, ppc64el, aarch64/arm64
18.04 bionic x86_64, aarch64/arm64
19.10 eoan x86_64
20.04 focal  x86_64, aarch64/arm64

installing nginx from Ubuntu Repository

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

 

 

 

2. Prebuilt Ubuntu Package from the Official NGINX Repository

 

a.

Ubuntu

Install the prerequisites:

sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring

 

Import an official nginx signing key so apt could verify the packages authenticity. Fetch the key:

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
    | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

Verify that the downloaded file contains the proper key:

gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg

The output should contain the full fingerprint 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 as follows:

pub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
      573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid                      nginx signing key <signing-key@nginx.com>

If the fingerprint is different, remove the file.

To set up the apt repository for stable nginx packages, run the following command:

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

If you would like to use mainline nginx packages, run the following command instead:

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

 

Set up repository pinning to prefer our packages over distribution-provided ones:

echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
    | sudo tee /etc/apt/preferences.d/99nginx

 

To install nginx, run the following commands:

sudo apt update
sudo apt install nginx

 

explained

Before installing nginx make sure to know which module need to add follow nginx modules list

https://nginx.org/en/linux_packages.html

Install the prerequisites:

sudo apt install curl gnupg2 ca-certificates lsb-release

a.Add nginx keys

sudo wget https://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key

Verify that you now have the proper key:

sudo apt-key fingerprint ABF5BD827BD9BF62

b. add nginx repository apt sources list

nano /etc/apt/sources.list

deb https://nginx.org/packages/mainline/ubuntu/ <CODENAME> nginx
deb-src https://nginx.org/packages/mainline/ubuntu/ <CODENAME> nginx

Mainline or stable

codename = replace with ubuntu 20.04 or 18.04 bionic version

mycase:

deb https://nginx.org/packages/mainline/ubuntu/ focal  nginx
deb-src https://nginx.org/packages/mainline/ubuntu/ focal  nginx

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

check nginx installed version

nginx -V

check whether it(nginx status modules)  enabled or not

nginx -V 2>&1 | grep -o with-http_stub_status_module

root@instance-1:~# nginx -v
nginx version: nginx/1.19.6 (changelog

install nginx with stub status module & Brotil

./configure

–with-http_stub_status_module

–with-compat –add-dynamic-module=../ngx_brotli

 

Next Follow LEMP Stack Installation Process or mysql installation ubuntu,

php -fpm installation on ubuntu

 

Upgrading Nginx to latest version ubuntu

by default the command

sudo apt-get install nginx  installs lower version,

you can upgrade by  adding new repo files from above

 

 

Primary Sidebar

nginx server tutorials (installation, configuration, performance tuning, security)

  • Letsencrypt SSL Installation on apache/Nginx ubuntu / debian wordpress
  • fix error 520 522 524 on cloudflare wordpress godaddy nginx etc
  • nginx fastcgi cache wordpress how to configure
  • install LEMP Stack on 22.04 LTS Nginx MySQL PHP fpm #wordpress #digital ocean
  • Apache vs nginx (connection handling, modules, memory usage)
  • Pagespeed module install, configure, monitor, errors ft nginx &apache
  • nginx errors (504,502, 413, unable to start, syntax errors)
  • nginx conf explained best config file performance tuning tips nginx.conf location errors tutorial
  • use nginx as reverse proxy and load balancer for apache wordpress
  • nginx rewrite rules with examples 301 redirection
  • nginx modules list (enable, disable, upgrade, install dynamic module)
  • php fpm pool manager configuration settings based on server spike high cpu wordpress
  • php fpm restart nginx ubuntu enable status page, monitor etc
  • what is TTFB & how to Reduce it (server response time) Google pagespeed
  • letsencrypt install configure on ubuntu / debian nginx
  • Top 10 tips to improve nginx server security
  • nginx performance tuning connections, buffers file descriptors
  • enable brotli compression nginx brotli vs gzip
  • nginx installation on ubuntu 20.04 LTS
  • monitor nginx request with nginx status amplify datadog new relic
  • SSL faster reduce TLS hand shake improve https performance
  • nginx rate limiting explained by location time specific url
  • datadog nginx integration installation process
  • newrelic nginx integration process and errors fix and metrics
  • php fpm seems busy fixed warning and max children reached to handle max connections / requests
  • Php fpm configuration for 1000 concurrent connections server busy max children reached
  • php fpm ondemand vs dynamic vs Static (the dynamic pool problem)
  • nginx upstream response is buffered to a temporary file
  • php fpm install ubuntu 20.04 nginx
  • install phpmyadmin ubuntu nginx 22.04
  • upgrade php fpm ubuntu nginx 7.4 to 8.2
  • nginx add last modified header (remove, php wordpress)
  • php fpm dynamic pool manager settings
  • nginx fastcgi cache purge
  • nginx open file limit connections ulimits sysctl
  • php fpm high cpu usage WordPress 4 solutions nay work for you
  • nginx buffer size for wordpress
  • Cloudflare error code 524 nginx a timeout error occured
  • server configuration for 1000 concurrent users

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy