πŸ–₯️ 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 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 *