Windows 2019
Sponsored Link

IIS : Add Web Sites2019/08/29

 
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 "NewSite" -Port 80 -HostHeader "RX-8.srv.world" -PhysicalPath "C:\inetpub\newsite" 

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

PS C:\Users\Administrator> Get-Website 

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:
NewSite          2    Started    C:\inetpub\newsite             http *:80:RX-8.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-8.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