DEV Community

Cover image for Creating a Linux VM and installing nginx on it

Creating a Linux VM and installing nginx on it

As discussed in the previous resource, setting up a virtual machine (VM) in the cloud is an essential skill for developers, system administrators, and anyone looking to manage applications in a scalable and flexible environment. In this guide, we’ll walk through the process of creating a Linux VM and installing the popular web server, NGINX, on it. Whether you're hosting websites, building applications, or managing network traffic, NGINX is known for its high performance, stability, and low resource consumption. By the end of this guide, you’ll have a fully operational Linux VM with NGINX installed, ready to serve web pages or power your applications. Let's begin!


Step-by-Step Guide to Creating a Linux VM and installing nginx on it

Step 1: Create a New Virtual Machine (VM)

  • From the list of search results, click on the Virtual Machine option. The best option is usually highlighted.

Virtual Machine

  • Click the Create button to start the virtual machine creation process. Choose Create a virtual machine hosted by Azure.
    Create

  • Select the appropriate subscription and create a resource group by clicking the Create resource group button. Give both the Resource group and the VM a name.
    Image description

Step 2: Configure the Virtual machine (VM)

  • Provide other information about your virtual machine, such as the operating system (Ubuntu Server 20.04), size, and other configuration settings. Leave other options as default.
    operating system

  • Create an Administrator Account. Use Azureuser for the username and password123 for the password.
    Administrator Account

  • Select Inbound Port Rules. Select SSH if you chose a Linux VM. This allows IP addresses to connect to the VM.
    Inbound Port Rules

  • Click Next until you reach the Boot diagnostics in the Monitoring tab, click on Disable, then click Review + Create.
    Disable Boot Diagnostics

  • Click on the Create button. If the validation passes, the deployment will proceed. If not, note any recommendations, fix them, and try again. Deployment might take 3-5 minutes.
    Create
    Go to resources

Step 3: Access the Linux Virtual machine

  • Once your VM is deployed, find its Public IP Address in the Overview tab.
    Public IP Address

  • Open a terminal (like Windows Powershell or use an SSH client like PuTTY) and connect to your VM using SSH:

ssh <username>@<Public-IP-Address>
Enter fullscreen mode Exit fullscreen mode
  • Replace and with your VM’s details.
  • Enter yes and then your password (not visible while typing in Linux).
  • Make sure that you are logged in as root use the command - sudo su.
- sudo su
Enter fullscreen mode Exit fullscreen mode

Access the Linux VM

  • Once connected, run the following commands to ensure the package list is up-to-date:
apt update
Enter fullscreen mode Exit fullscreen mode

Package Update

Step 4: Install nginx on a Linux Server

  • Type the command - apt install nginx. apt (Is the package manager of nginx), install (This is a verb and the action that you want the package manager to perform), nginx (This is what you want to install on the VM).
apt install nginx
Enter fullscreen mode Exit fullscreen mode

Install nginx

Image description

step 5: Test NGINX Installation

  • We can verify this installation by pasting the IP Address of the VM in a browser. Test NGINX Installation

By following these steps, you’ve successfully created a Linux VM in Azure and installed NGINX. This setup is ready to serve web traffic and can be scaled based on your requirements. You can now begin deploying web applications or customizing NGINX as needed.


Thank you for reading my blog.😊😊

If you need further assistance, feel free to reach out in the comment or hit me up on Twitter. You can also follow me on GitHub. My DM's are open and love discussions on cloud topics!😁

Top comments (2)

Collapse
 
realcloudprojects profile image
Skill Schule

Welldone!

Collapse
 
toluwani_oluwaloseyi profile image
Toluwani Oluwaloseyi

This was very insightful. Thank you for sharing.