Host/Deploy Website on Azure Virtual Machine Ubuntu Linux Server

How to Host a Static Website on Azure Virtual Machine (Ubuntu + Nginx)

Cloud computing allows developers and engineers to deploy applications and websites easily without managing physical infrastructure. One of the most practical beginner cloud projects is hosting a website on a virtual server.

In this guide, you will learn how to host a static website on a Microsoft Azure Virtual Machine using Ubuntu Linux and Nginx. This hands-on tutorial walks through the entire process from creating the virtual machine to deploying the website template and mapping a domain name.

This project is perfect for cloud engineers, DevOps beginners, and system administrators who want to gain practical experience with cloud infrastructure.


Prerequisites

Before getting started, make sure you have the following:

  • A Microsoft Azure account

  • Basic knowledge of Linux commands

  • A terminal tool such as MobaXterm or PuTTY

  • A website template for deployment


Step 1: Create an Azure Virtual Machine

  1. Log in to the Azure portal.

  2. Search for Virtual Machines in the dashboard.

  3. Click Create and select Virtual Machine.

Under the Basics tab, configure the following:

  • Create a new Resource Group.

  • Enter a Virtual Machine Name.

  • Select your Region.

  • Choose Ubuntu Server as the image.

  • Select x64 architecture.

To reduce costs, enable Azure Spot Instance.

Under Administrator Account:

  • Select Password authentication.

  • Enter a username and password.

For Inbound Port Rules, allow:

  • SSH (Port 22) – for server management

  • HTTP (Port 80) – for web access


Step 2: Configure Networking

When you proceed to the Networking tab, Azure automatically creates:

  • A Virtual Network (VNet)

  • A Subnet

  • A Public IP Address

You can rename these resources if desired.

Make sure the Network Security Group (NSG) allows inbound traffic on:

  • Port 22 (SSH)

  • Port 80 (HTTP)

Once everything is configured:

  1. Click Review + Create

  2. Wait for validation

  3. Click Create

Azure will deploy the virtual machine along with all required networking resources.


Step 3: Connect to the Virtual Machine

After deployment:

  1. Navigate to the Virtual Machine dashboard.

  2. Click Connect at the top.

  3. Select SSH.

Copy the SSH command displayed.

You can use a terminal tool like MobaXterm to connect to the server.

To connect using MobaXterm:

  1. Open MobaXterm.

  2. Click Session → SSH.

  3. Enter the Public IP address of the VM.

  4. Enter the username created during VM setup.

  5. Ensure the port number is 22.

  6. Click OK and enter your password.

You are now connected to your Linux server.


Step 4: Update and Patch the Server

Before installing software, update the system packages.

Run the following commands:

sudo apt update
sudo apt upgrade -y

To check packages that require upgrades:

apt list –upgradable

Keeping your system updated helps prevent vulnerabilities.


Step 5: Install Nginx Web Server

Nginx will serve the website from your server.

Install it with the command:

sudo apt install nginx -y

Check if Nginx is running:

sudo systemctl status nginx

If the service is active, your server is ready to host a website.


Step 6: Navigate to the Nginx Web Directory

The default website files are stored in:

/var/www/html

Use these commands to navigate there:

cd /var
ls
cd www
ls
cd html

Inside this folder you will find the default Nginx page:

index.nginx-debian.html

To view its content:

cat index.nginx-debian.html

To remove it before uploading your own website:

sudo rm index.nginx-debian.html

Step 7: Upload a Website Template

You can download free HTML templates from:

https://themewagon.com/theme-tag/html5-css3/

Upload the template to your server using MobaXterm’s file transfer feature.

If the file is compressed, install unzip:

sudo apt install unzip -y

Extract the template:

unzip foldername.zip

To view the extracted files:

ls -la foldername

Copy the website files to the Nginx web directory:

sudo cp -r foldername/* /var/www/html

Your website files are now deployed.


Step 8: Test the Website

Open a browser and enter your server’s Public IP address:

http://YOUR-IP-ADDRESS

If everything is configured correctly, your website will load.


Step 9: Map Your Domain Name (Optional)

Instead of accessing the site using an IP address, you can map a domain.

Steps:

  1. Log in to your domain registrar.

  2. Navigate to DNS Management.

  3. Add a new record.

Configuration:

Type: A Record
Host: @
Value: Server Public IP

Save the record.

DNS propagation may take some time.

You can verify propagation using:

https://www.dnschecker.org


Conclusion

In this tutorial, you learned how to:

  • Create an Azure Virtual Machine

  • Configure networking and security groups

  • Connect to the server using SSH

  • Install and configure Nginx

  • Upload a static website

  • Access the site through an IP address or domain

This project demonstrates a fundamental cloud engineering workflow and is an excellent starting point for building practical Azure skills.


Watch the Full Video Tutorial

You can watch the complete step-by-step demonstration here:


If you are learning cloud engineering, DevOps, or Linux server administration, projects like this help build real-world experience.

Frequently Asked Questions (FAQ)

1. What is a Virtual Machine in cloud computing?

A virtual machine (VM) is a software-based computer that runs on physical hardware in a cloud environment. In platforms like Microsoft Azure, a virtual machine allows you to run operating systems such as Ubuntu or Windows Server and host applications, websites, and services without owning physical servers.


2. Why use an Azure Virtual Machine to host a website?

Hosting a website on a virtual machine provides full control over the server environment. With an Microsoft Azure VM, you can:

  • Install any software you need

  • Configure networking and security settings

  • Deploy custom applications

  • Scale resources when traffic increases

It is a common practice for cloud engineers and DevOps professionals.


3. What is Nginx and why is it used for hosting websites?

Nginx is a high-performance web server used to serve websites and web applications. It is popular because it:

  • Handles large numbers of users efficiently

  • Consumes fewer system resources

  • Works well as a reverse proxy and load balancer

In this tutorial, Nginx is used to serve the static website from the Ubuntu server.


4. What is SSH and why is it needed?

Secure Shell (SSH) is a secure protocol used to remotely access and manage servers. It allows administrators to connect to cloud servers from their local computers and execute commands safely over an encrypted connection.

In this project, SSH is used to connect to the Azure Virtual Machine and configure the Linux server.


5. What is a Virtual Network (VNet) in Azure?

A Virtual Network (VNet) in Microsoft Azure is a private network that allows cloud resources like virtual machines to communicate securely with each other and with the internet.

VNets help organize cloud infrastructure and control network traffic.


6. What is a Network Security Group (NSG)?

A Network Security Group (NSG) is a security feature in Azure that controls inbound and outbound traffic to resources.

For example, in this project we allowed:

  • Port 22 for SSH access

  • Port 80 for HTTP web traffic

This ensures that only necessary traffic is allowed to reach the server.


7. Can I host a website on Azure for free?

Yes, depending on your subscription and usage. Microsoft Azure offers free credits and some limited free services for new users. However, virtual machines typically incur charges based on:

  • Compute usage

  • Storage

  • Network traffic

Using Azure Spot Instances can significantly reduce costs.


8. What is a static website?

A static website consists of fixed files such as:

  • HTML

  • CSS

  • JavaScript

  • Images

Unlike dynamic websites, static websites do not require a backend database or server-side scripting.

Static sites are faster, simpler, and easier to deploy on servers like those running Nginx.


9. How can I connect a domain name to my Azure server?

To connect a domain name to your server:

  1. Log in to your domain registrar.

  2. Go to the DNS management section.

  3. Create an A Record pointing to your server’s public IP address.

Once DNS propagation completes, users can access your website using the domain instead of the IP address.


10. Is hosting a website on a cloud VM a good project for beginners?

Yes. Hosting a website on a virtual machine is one of the best beginner cloud projects because it teaches multiple important concepts:

  • Cloud infrastructure deployment

  • Linux server administration

  • Web server configuration

  • Networking and security

  • DNS management

These are foundational skills for cloud engineers and DevOps professionals.

Leave a Reply

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