DEV Community

Izuabueke Davidson  Anujulu
Izuabueke Davidson Anujulu

Posted on

HOW TO CREATE A WEB SERVER AND INSTALL SERVER ROLE ON A WINDOWS VIRTUAL MACHINE

Table Of Contents

Step-by-Step Guide.

Step1:

Create a Windows Virtual Machine in Azure

To create a Windows Virtual Machine, in the search bar, type and select Windows Server.
Windows Server
On the page, click Create and select Virtual Machine.
Create and select Virtual Machine

Configure Basics

Project details: I will choose my subscription and resource group (or create a new one).
In this case, I will create a new one with the name RG
Instance details:
VM name (e.g., WebServerVM)
Region (I will choose the closest location )
Availability options: Leave default
Image: Windows Server 2025 Datacenter, which is the latest
Size: Choose an appropriate size (e.g., Standard B1s for testing)
Note If you use Standard B1s, there will be an error in the installation of the IIS Web Server. There are two ways to solve this challenge, first, from the creation choose the size from Standard_DS1_v2 and above.
Second, after creation, from the VM settings, increase the memory.

Configure Basics

Configure Basics

Administrator account
This is where I will provide my login details, which will include
Username and Password
Confirm password
Inbound port rules
Select which virtual machine network ports are accessible from the public internet. You can specify more limited or granular network access on the Networking tab.
Public inbound ports:
None
Allow selected ports

Select inbound ports: You can select one or more.
RDP (3389) HTTP (80) HTTPS (443)
SSH (22)
This will allow all IP addresses to access your virtual machine. This is only recommended for testing. Use the Advanced controls in the Networking tab to create rules to limit inbound traffic to known IP addresses.
Administrator account

Configure Disks

Use defaults unless you have special requirements.
OS disk
OS disk size: The choice of disk size is dependent on your needs. but the Image default is(127 GiB)
OS disk type: This disk type is dependent on your workload, for the purpose of this web server i will use Standard SSD (locally-redundant storage).

Data disks for WebServerVM
You can add and configure additional data disks for your virtual machine or attach existing disks. This VM also comes with a temporary disk.

Create and attach a new disk.
To create a new disk, all you have to do is click on Create it will open another page where you can file Name
WebServerVM_DataDisk_0, choose Source type, then click on change size to choose the Size you need and select ok.

Attach an existing disk
When you click on attach, it will show you the list of existing disks you one
Configure Disks

Configure Networking

A Virtual Network (VNet) is a software-defined network in the cloud that allows Azure resources (like virtual machines, databases, apps) to communicate securely with each other, with the internet, and with on-premises networks.
I will discuss more about Networking later.
Virtual network: New or existing
Subnet: Default
Public IP: Create new (name like webserverpublicip)
NIC network security group: Choose Basic or Advanced
If using basic, allow HTTP (Port 80) and RDP (Port 3389) by checking the boxes below.
Image description

Review and Create
Click Create
Click Create

Step 2:

Connect to Your VM via RDP

  1. Go to the VM Overview page

Go to the VM
Once deployment is complete, click Connect > RDP
Download the RDP file.
Connect > RDP

From the Download, open the file and click connect
open the file

  1. Log in with the credentials you set during creation

Image description
Once you are connected to your machine using remote desktop protocol(rdp) file and you are now on the desktop page, you can test your virtual machine for web server by copying the the public ip address and running it on a browser.
public ip address
Note this may fail because of two things: one web server has not been installed, which is true in this case.
Two, if HTTP Inbound port rules have not been created or are set to deny.

Step 3:

Install Web Server Role (IIS)

Open Server Manager
When you log in to the VM, the Server Manager will open automatically after login, but if it does not, search for Server Manager in the search bar and click it.
Add Roles and Features
On Server Manager, in the top right corner, click on Manage, Add Roles and Features.
Add Roles and Features.

Follow the Wizard
Before You Begin : Next
Select installation type : Role-based or feature-based installation → Next
Image description
Select destination server : Pick your server → Next
destination
Select server roles : Check Web Server (IIS)

Image description
A popup appears; accept adding required features
Select features : Leave default unless you need something specific
Confirm installation selections : Next
Install
Install
Wait while IIS installs.
IIS installs
Note: The installation failed while installing it through the server manager because of low memory in the VM.

Likewise, installation through PowerShell

I install it through PowerShell, on the search bar type PowerShell, right click on it and select Run as administrator.
Image description
Once the PowerShell pane opens, type in the following code: Install-WindowsFeature Web-Server.

Note that it is case sensitive.
The start installation will be displayed
Image description
After the installation, you will see this
Image description

Note This installation failed because in the Instance details section on Size I Choose Standard B1s which have low memory.
As I said before, there are two ways to solve this challenge, first, from the creation choose the size from Standard_DS1_v2 and above.
Second, after creation, from the VM settings, increase the memory.

Increase the VM memory
Type PC and right-click on This PC/My Computer, click on Properties
Properties
On the next page, scroll to Advanced system settings and click it.
Properties
Under the Advanced tab → click Settings under Performance.
Settings
Go to the Advanced tab again → click Change under Virtual memory.

Virtual memory
Uncheck Automatically manage paging file size for all drives .
Select the system drive (usually C:) → choose Custom size .
Set a larger Initial size (MB) and Maximum size (MB) .
Image description
Click ok on all the pop-ups, on the last one after clicking ok then click close.

I have increased my VM memory. I will restart the VM and go to the server manager and click on Manage, then Add Role and Feature, complete the steps, and this is the result
complete the steps

Remove the Windows Server IIS

From the Server Manager, select Manage, click Remove Roles and Features.
Remove Roles
On Before you begin, click Next and Next
Image description
On the server Role, uncheck the box and click next and next
server Role
On the Confirmation, click Remove
Confirmation
The removal will be initiated
initiated

Removal completed
Removal completed

Now that I have increased the VM memory, let's install Windows Server IIS through PowerShell

I will install it through PowerShell again. In the search bar, type PowerShell, right click on it and select Run as administrator.
Image description
Once the PowerShell pane opens, type in the following code: Install-WindowsFeature -name Web-Server -IncludeManagementTools.

Note that it is case sensitive.
The start installation will be displayed

start installation
After the installation, you will see this.
After the installation

Step 4:

Test the Web Server

copying the public IP address
Image description

searching it on a browser
browser

Thanks for reading till the end, hope you learn something.
you can put your comment, Like and Share with your friends.

Top comments (0)