• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

How To Install Nginx On Ubuntu 22.04 LTS

March 5, 2023 by Sharad Chhetri Leave a Comment

In this tutorial, we will show the manual as well as bash script method to install Nginx on Ubuntu 22.04 LTS server. Nginx which is one the most powerful web server widely use in the IT industry. It can easily handle the thousands of simultaneous connections with the small memory usage.

Usage of Nginx:

  1. Web Server
  2. Caching Server
  3. Reverse Proxy,
  4. Load Balancer
  5. Mail Proxy

In many CDN Network the backend servers are mostly Nginx Server. So by this only you can imagine how dynamic and powerful it is.

Let’s start the installation for which you might be waiting for. We expect you have already installed the Ubuntu 22.04 LTS Server in your machines.

If you are DevOps aspirant then we will strongly suggest to automate each single bit of your task. For this you can use scripting like bash, python etc and tools like Ansible, Chef, Puppet etc.

We have also created a simple bash script for installing the Nginx its Github link is at the end of this post.

Install Nginx On Ubuntu 22.04 LTS (Manual Method)

We have checked this method in Ubuntu 22.04 LTS, this should work with other Ubuntu versions also. You can share your practical result in comment sections and help others to know.

  1. Open the terminal and run the following commands.
  2. Install the dependencies
    sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring -y 
  3. Add the signing key
    curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \ | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null 
  4. Add the apt repo file
    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 
  5. Pin the preference
    echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \     | sudo tee /etc/apt/preferences.d/99nginx
  6. Install the Nginx after updating the apt repo
    sudo apt update -y sudo apt install nginx -y
  7. Now restart the nginx service
    sudo systemctl restart nginx
  8. Now open the Web Browser and type the URL or IP Address of the Nginx Server. Check you Linux Machine ip address by typing command ip a. In web browser, it will open the Nginx default page.

Once you have installed the Nginx, you will also be interested to know how to stop/start/restart the Nginx Service. So here are the commands.

For stopping the Nginx Service

sudo systemctl stop nginx

For Starting the Nginx Service

sudo systemctl start nginx

For Restarting the Nginx Service

sudo systemctl restart nginx

Install Nginx On Ubuntu 22.04 LTS By Using Bash Script

The bash script we have kept in our Github repo from where you can pull and use it. You can find the Github Repo link here.

Download the bash script and give execute permission to the script. chmod 750 install_nginx_ubuntu.sh

Now run the script sh install_nginx_ubuntu.sh . It will install the Nginx.

Now open the web browser and give ip address or FQDN of the Server in address field. It will open the default page.

Install Nginx On Ubuntu 22.04 LTS

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Can’t load ‘/usr/local/lib64/perl5/auto/nginx/nginx.so’
  2. Install Nginx from source code on Ubuntu 14.04 LTS
  3. Install and compile nginx 1.14 on Ubuntu 18.04 LTS server
  4. How to install nginx webserver from source on CentOS and RHEL
  5. How to install nginx from source on CentOS 7
  6. Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)
  7. Upgrade Ubuntu 14.04 LTS to Ubuntu 14.04.3 LTS
  8. How to run django with nginx
  9. Nginx : could not build the server_names_hash, you should increase server_names_hash_bucket_size
  10. Configure Nginx for Jekyll / Octopress / pelican based static website

Filed Under: Linux Tagged With: bash script, linux, nginx, ubuntu, ubuntu 22.04 lts

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

Linux command : To create new directory/folder

How to print particular line number by using sed command

print working directory ( pwd , PWD , OLDPWD ) in Linux / Unix

man command not found in CentOS and Red Hat

Learn tar command and know about its precaution

How to extract RPM package on Linux system

How to test rpm package before installation

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

fatal error: error writing to /tmp/ccwAjc9Z.s: No space left on device

safest method to remove softlink in linux

How to install korn shell ksh in Linux

sed: -e expression #1, char 24: Invalid range end

Keep logs of user after sudo su – : Secondary Logging

WordPress host IP changed not able to open wp-admin and site page looks scattered

How to use grep command to get fixed pattern or exact keyword

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy