๐ฅ๏ธ 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
- An active Azure subscription
- A basic static website project: ๐ฆDownload link
- Basic familiarity with navigating the Azure Portal
- You have MobaXterm installed (Free download: https://mobaxterm.mobatek.net/)
๐ง Step 1: Create a Linux Virtual Machine
- Go to Azure Portal.
- In the left-hand menu, click “Virtual Machines” > “Create” > “Azure virtual machine”.
- 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)
- Click “Review + Create” and then “Create”.
๐ Step 2: Open MobaXterm and Start a New SSH Session
- Open MobaXterm
- Click on “Session” (top left)
- Choose SSH
- 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):
- 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
- Click OK or Save & Connect
- MobaXterm will initiate an SSH session and open a terminal
- 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.
- 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.
- 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”.
- This panel shows the remote file system of your VM (e.g.,
- 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).
- 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.
- The files will transfer to the current directory shown in the left panel (e.g.,
โ 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!
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.
Feature | Self-Paced Training | Live 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 Info | Explore Self-Paced Training | Explore Live Training |