π₯οΈ 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
.pemfileΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β π 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 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 |
