Windows 2022
Sponsored Link

IIS : Add Web Sites2022/01/26

 
Add new Web Sites on IIS.
This setting is like the Virtual Hosting on Apache httpd that is often used on Unix/Linux.
[1] Run PowerShell with Admin Privilege and Configure.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# current Web Sites list
PS C:\Users\Administrator> Get-Website 

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:

# for example, add [NewSite] Site
# physical path [C:\inetpub\newsite], hostname [rx-8.srv.world]
PS C:\Users\Administrator> mkdir C:\inetpub\newsite 
PS C:\Users\Administrator> New-WebSite -Name "RX-7.srv.world" -Port 80 -HostHeader "rx-7.srv.world" -PhysicalPath "C:\inetpub\newsite" 

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
RX-7.srv.world   2    Started    C:\inetpub\newsite             http *:80:rx-7.srv.world

PS C:\Users\Administrator> Get-Website 

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:
RX-7.srv.world   2    Started    C:\inetpub\newsite             http *:80:rx-7.srv.world

# create a test page
PS C:\Users\Administrator> Write-Output "IIS Virtual Host Test Page" | Out-File C:\inetpub\newsite\index.html -Encoding Default 

# verisy accesses
# default site
PS C:\Users\Administrator> curl.exe localhost 
IIS Default Start Page

# new site
PS C:\Users\Administrator> curl.exe rx-7.srv.world 
IIS Virtual Host Test Page
IIS : Add Web Sites (GUI)
 
On GUI configuration, set like follows.
[2] Run [Start] - [Server Manager] and Click [Tools] - [Internet Information Services (IIS) Manager], and then Right Click [Sites] on the left pane and Select [Add Website].
[3] Input any Site name (it is used on IIS Manager) for [Site name] field, for [Physical path] field, input Physical folder Path for this new site, and for [Host name], input server's hostname.
[4] If added normally, new Web Site is displayed on Sites list.
[5] Create a test page for new Web Site and verify accesses.
Matched Content