DEV Community

Olalekan Oladiran
Olalekan Oladiran

Posted on • Edited on

6

HOW TO INSTALL NGINX WEB SERVER ON LINUX VIRTUAL MACHINE

Introduction

NGINX is a popular open-source web server known for its high performance, reliability, and scalability. Initially released in 2004, it has since gained widespread adoption and is commonly used as a web server, reverse proxy server, load balancer, and HTTP cache.

Installing Nginx web server

After creating linux virtual machine, you can install Nginx web server using the following steps:

  1. Find out what IP address your Linux virtual machine is publicly known as using the code: az vm list-ip-addresses --name MyVM --output table. The name of the virtual machine created virtual machine is MyVM Image description
  2. After obtaining the Public IP address from the previous step, establish an SSH connection to MyVM using the code ssh azureuser@ip-address

Image description
3.To install the nginx web server, enter the following command after logging into the virtual machine. It will take a few moments to finish the command.
sudo apt-get -y update && sudo apt-get -y install nginx
Image description

  1. quit the secure shell using the code exit Image description

How to get default webpage

  1. To access the default page from your Linux web server using curl in Azure Cloud Shell, use the following command, changing to the public IP you previously discovered. Another option is to try opening a new tab in your browser and accessing the public IP address. curl -m 80

Image description

Image description
The reason this command fails is that the network security group that protects the virtual machine's network connectivity does not allow the Linux virtual machine to expose port 80 (http). By using the Azure CLI command vm open-port, we can resolve the issue.

  1. To open port 80 in Cloud Shell, enter the following command: az vm open-port \ --port 80 \ --resource-group MyResourceGroup \ --name MyVM

Image description

  1. Use the curl command once again.

Image description
This time, the following data should be returned. The page is also visible in a browser by searching the ip address in a browser.

Image description

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay