DEV Community

Tomiwa Ogunleye
Tomiwa Ogunleye

Posted on

Deploying to Windows 11, Windows Server, and EC2 Instances

Deploying to Windows 11, Windows Server, and EC2 Instances

Introduction

Deploying virtual machines (VMs) in various environments such as Windows 11, Windows Server, and AWS EC2 is essential for setting up development and production systems. This guide focuses on setting up a Windows 11 VM in Azure, with additional sections covering Windows Server and EC2.


Deploying to Windows 11: Setting Up a Virtual Machine in Azure

Prerequisites

Before proceeding, ensure that:

  • You have an Azure account with the necessary permissions to create virtual machines.
  • You have selected the appropriate VM size and image for Windows 11.
  • You have configured networking and security settings properly.

Creating a Windows 11 Virtual Machine in Azure

  1. Log into Azure Portal: Go to Azure Portal and navigate to Virtual Machines.
  2. Create a New VM:
    • Click Create > Azure Virtual Machine.
    • Select Windows 11 as the image.
    • Choose an appropriate VM size (at least 4 vCPUs and 8GB RAM recommended).

Image description

  1. Configure Networking:
    • Ensure that RDP access is enabled (port 3389).
    • Set up a public or private IP as needed.

Image description

  1. Set Up Disk and Storage:
    • Use a managed disk with at least 64GB storage.
  2. Create and Deploy the VM:
    • Review settings and click Create.
  3. Connect to the VM:
    • Once deployed, use Remote Desktop (RDP) to connect by entering the public IP and logging in with the configured credentials.

Image description

Image description

Image description

Post-Installation Steps

Once Windows 11 is installed in the VM:

  • Install necessary drivers and updates.
  • Configure firewall and security settings.
  • Set up remote access and enable necessary software.

Conclusion

By following these steps, you have successfully deployed a Windows 11 virtual machine in Azure.


🌐 Deploying a Web Server VM and Installing IIS on Windows

πŸš€ Step 1: Create a Web Server VM in Azure

Ensure that when creating the VM, you select a Windows Server image.

πŸ’» Step 2: RDP into the VM

On Windows:

  1. Open Remote Desktop Connection (RDP)
  2. Enter the public IP address of the VM
  3. Click Connect
  4. Enter your Admin username & password
  5. Click OK

⚑ Step 3: Open PowerShell as Administrator

Install-WindowsFeature -name Web-Server -IncludeManagementTools
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

βœ… Step 5: Verify IIS Installation

πŸ“Œ Method 1: Localhost

http://localhost
Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Method 2: Public IP Address

http://<your_vm_ip>
Enter fullscreen mode Exit fullscreen mode

Image description

πŸ› οΈ Troubleshooting

  • IIS Not Running?
  Start-Service W3SVC
Enter fullscreen mode Exit fullscreen mode
  • Can't Access the Web Page?
  New-NetFirewallRule -DisplayName "Allow HTTP" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow
Enter fullscreen mode Exit fullscreen mode
  • Restart IIS if needed:
  Restart-Service W3SVC
Enter fullscreen mode Exit fullscreen mode

πŸ” Basic SSH Commands in Azure & Linux

SSH (Secure Shell) allows secure remote access to Linux servers. Below are the essential SSH commands and their usage.

πŸ“Œ Basic SSH Syntax

ssh username@hostname_or_ip
Enter fullscreen mode Exit fullscreen mode
  • username β†’ The user account you want to log in with.
  • hostname_or_ip β†’ The IP address or domain name of the remote server.

πŸ”‘ Example 1: SSH with Password Authentication

ssh azureuser@192.168.1.100
Enter fullscreen mode Exit fullscreen mode

πŸ” Example 2: SSH with a Private Key (Identity File)

ssh -i /path/to/private/key user@192.168.1.100
Enter fullscreen mode Exit fullscreen mode

Image description
Image description

πŸ› οΈ Troubleshooting Tips

  • Permission Denied? Ensure your private key has the correct permissions:
  chmod 600 /path/to/private/key
Enter fullscreen mode Exit fullscreen mode
  • Connection Timed Out? Check if SSH is enabled and port 22 is open.

πŸš€ Copying Files Over SSH

scp -i /path/to/private/key localfile.txt user@192.168.1.100:/remote/directory/
Enter fullscreen mode Exit fullscreen mode

Deploying an EC2 Instance in AWS and Installing Nginx

Prerequisites

Ensure you have:

  • An AWS account with permissions to create EC2 instances.
  • A key pair for SSH access.

Creating an EC2 Instance

  1. Log into AWS Console: Go to AWS EC2 and navigate to Instances.
  2. Launch a New Instance:
    • Click Launch Instance.
    • Choose Ubuntu as the image (latest LTS version recommended).
    • Select an instance type (t2.micro is free-tier eligible).
    • Configure networking and security settings (ensure SSH and HTTP access are allowed).
    • Assign an existing key pair or create a new one.

Image description
Image description
Image description

  1. Launch and Connect:

    • Click Launch.
    • Once running, connect using SSH:
     ssh -i /path/to/private/key ubuntu@your_ec2_ip
    

Image description

Installing Nginx on the EC2 Instance

  1. Update the package lists:
   sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode
  1. Install Nginx:
   sudo apt install nginx -y
Enter fullscreen mode Exit fullscreen mode

Image description
Image description

  1. Start and Enable Nginx:
   sudo systemctl start nginx
   sudo systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode
  1. Verify Installation:
   systemctl status nginx
Enter fullscreen mode Exit fullscreen mode

Image description

  1. Test in a Web Browser:

    • Copy the public IP of the instance and visit:
     http://your_ec2_ip
    

Image description

Troubleshooting

  • If Nginx is not running:
  sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode
  • Ensure the firewall allows HTTP traffic:
  sudo ufw allow 80/tcp
Enter fullscreen mode Exit fullscreen mode

βœ… Congratulations! πŸŽ‰ You have successfully set up an EC2 instance and installed Nginx.

Top comments (0)