fbpx

๐Ÿ–ฅ๏ธ Deploying a Static Website on Azure Linux Virtual Machine

๐ŸŒ Want to host your static website on the cloud quickly and affordably? Azure Static Web App is a powerful solution that makes it easy to deploy fast, secure, and scalable websites.

In this step-by-step guide, youโ€™ll learn how to deploy a static website on an Azure Linux Virtual Machine using tools like MobaXterm, Apache, and the Azure Portal. Whether you’re a beginner or exploring Azure deployment for the first time, this tutorial walks you through everything โ€” from setting up your VM to uploading your HTML files and making your website live.

โœ… Prerequisites

๐Ÿ”ง Step 1: Create a Linux Virtual Machine

  1. Go to Azure Portal.
  2. In the left-hand menu, click “Virtual Machines” > “Create” > “Azure virtual machine”.
  3. Fill in the Basics tab:
    • Subscription: Choose your subscription
    • Resource group: Create new or select existing
    • Virtual machine name: myStaticVM
    • Region: Choose a region (e.g., East US)
    • Image: Choose Ubuntu Server 22.04 LTS
    • Size: Choose a VM size (e.g., B1s for small site)
    • Authentication type: Choose SSH public key or password
    • Configure inbound port: Check HTTP (80) and SSH (22)
  4. Click “Review + Create” and then “Create”.

๐Ÿš€ Step 2: Open MobaXterm and Start a New SSH Session

  1. Open MobaXterm
  2. Click on “Session” (top left)
  3. Choose SSH
  4. In the session settings:
    • Remote host: Paste the public IP of your VM
    • Specify username: Enter your Azure VM username (e.g., azureuser)
    • Port: Keep as 22 (default SSH port)

๐Ÿ”‘ Step 3: Configure Authentication Method

๐Ÿ”ธ If using SSH private key (.pem):

  1. Under Advanced SSH settings (in the SSH session dialog):
    • Check “Use private key”
    • Browse and select your .pem fileย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย ๐Ÿ” You may need to convert .pem to .ppk using PuTTYgen if MobaXterm doesnโ€™t accept .pem.

๐Ÿ”ธ If using password authentication:

  • MobaXterm will prompt you for your password after initiating the connection.

โ–ถ๏ธ Step 4: Connect

  1. Click OK or Save & Connect
  2. MobaXterm will initiate an SSH session and open a terminal
  3. If credentials are correct, youโ€™ll be logged into your Azure VM!

๐ŸŒ Step 5: Install Web Server (via Azure Portalโ€™s SSH Console)

1. Once connected, run the following commands in the MobaXterm SSH terminal:

For Apache (alternative):

sudo apt update
sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2

โœ… Tip: Nginx is preferred for lightweight static hosting.

๐Ÿ“ค Step 6: Upload Static Website Files to Azure VM Using MobaXterm

Follow these steps to upload your HTML, CSS, JS, or entire static site files to your Azure VM through MobaXtermโ€™s built-in file browser.

  1. Log in to the VM using MobaXterm:
    • Open MobaXterm.
    • Start a new SSH session using your VMโ€™s public IP, username (e.g., azureuser), and authentication method (key or password).
    • Once connected, the remote terminal opens on the right.
  2. Use the file browser on the left panel:
    • This panel shows the remote file system of your VM (e.g., /home/azureuser).
    • You can navigate to the folder where you want to upload (e.g., /home/azureuser/site).
    • If the folder doesnโ€™t exist, create it by right-clicking and selecting “New Folder”.
  3. Click the “Upload” icon in the file browser panel:
    • This opens a file picker dialog from your local machine.
    • Select your static website files (e.g., index.html, style.css, or a whole folder).
  4. Confirm upload:
    • The files will transfer to the current directory shown in the left panel (e.g., /home/azureuser/site).
    • You can see the progress bar and confirm once files are fully uploaded.

โœ… After Upload: Deploy to Apache

Now that your files are uploaded to /home/azureuser/site, copy them to Apacheโ€™s web root:

sudo rm -rf /var/www/html/*
sudo cp -r /home/azureuser/site/*
/var/www/html/
sudo systemctl restart apache2

๐ŸŒ Access Your Website

Open a browser and go to:

http://< your-vm-public-ip >

Your static website should now be live!

๐Ÿง  Knowledge Check โ€“ Test Your Understanding

1 / 5

Which port must be open to access your website in the browser?

2 / 5

What is the default directory for Apache to serve web content?

3 / 5

Which of the following commands installs Apache on an Ubuntu server?

4 / 5

MobaXterm is used for:

5 / 5

After uploading website files, which command restarts the Apache server?

Your score is

The average score is 76%

0%

Devops Multi cloud Training

Choose the training style that fits your schedule โ€” Self-Paced or Live Interactive Sessions. Both include hands-on projects, expert support, and lifetime access.

FeatureSelf-Paced TrainingLive Training
๐ŸŽฏ Mode๐ŸŽฅPre-Recorded Session๐Ÿง‘โ€๐ŸซLive Class + Recordings
๐Ÿ’ผ Projects๐Ÿ•’ Weekend Real-Time Projects๐Ÿ“… Weekdays + Weekend Real-Time Projects
โ“ Doubt Clearing๐Ÿ“ž Weekend Live Support Session๐Ÿง  Anytime Doubt Clearing Session
๐Ÿ‘ฅ Career Support & MentorshipโŒ Noโœ… Yes
๐ŸŽ“ Global Certification TrainingโŒ Noโœ… Yes
๐Ÿ”‘ Accessโ™พ๏ธ Lifetime Accessโ™พ๏ธ Lifetime Access
๐Ÿ’ฐ Feesโ‚น4,999 (2 x โ‚น2,500)โ‚น7,999 (2 x โ‚น4,000)
โ„น๏ธ For More InfoExplore Self-Paced Training Explore Live Training

Leave a Comment

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

Open chat
Hello, Good day!!
How can we help you?