Hosting multiple websites on a single ECS instance reduces operational costs and simplifies management tasks, such as software updates, security configurations, and data backups. It also lets you flexibly allocate resources based on each website's needs. This topic describes how to use Internet Information Services (IIS) to host multiple websites on an ECS instance that runs Windows Server 2012 R2 64-bit.
Prerequisites
You have created an ECS instance and deployed a web environment. For more information, see Quickly deploy a BT-Panel.
In this tutorial, you will use IIS on Windows to build two test websites, windows-testpage-1 and windows-testpage-2. You will configure them to be accessible through different domain names on the same port.
Create the test websites
-
Establish a remote connection to the ECS instance where the web environment is deployed.
For more information, see Connect to a Windows instance by using Workbench.
-
On the desktop, click This PC and navigate to the default website root directory at
C:\wwwroot. -
Create two folders named
windows-testpage-1andwindows-testpage-2.
-
In the
windows-testpage-1folder, create a test file named test1.php with the following content.<?php echo "<title>Test-1</title>"; echo "windows-test-1"; ?> -
In the
windows-testpage-2folder, create a test file named test2.php with the following content.<?php echo "<title>Test-2</title>"; echo "windows-test-2"; ?>
Configure the IIS server
-
On the taskbar, click the Server Manager icon
. -
In the top menu bar, click .
-
In the navigation pane on the left of IIS Manager, click the server name, and then click Sites.
-
In the Actions pane on the right, click Add Website.... Add the
windows-testpage-1test website, and then click OK.The website is configured as follows:

Parameters:
-
Site name: Enter
windows-testpage-1. -
Application pool: DefaultAppPool
-
Physical path: Specify the physical path to the
windows-testpage-1folder. -
Host name: Enter the test domain name
test1.com.
-
-
In the Actions pane, click Add Website... again. Add the
windows-testpage-2test website, and then click OK.The website is configured as follows:

Parameters:
-
Site name: Enter
windows-testpage-2. -
Application pool: DefaultAppPool
-
Physical path: Specify the physical path to the
windows-testpage-2folder. -
Host name: Enter the test domain name
test2.com.
After the websites are added, they appear as shown in the following figure.

-
(Optional) Configure the local hosts file
Because this tutorial uses test domain names, you need to configure IP address mapping in the hosts file on your on-premises host. If you are using real domain names to configure your websites, you can skip this step. This tutorial assumes your on-premises host runs Windows.
-
Navigate to the
C:\Windows\System32\drivers\etcdirectory. -
Create a backup of the hosts file.
Keep the
hosts - copyfile to restore the original hosts file after testing. -
Modify the hosts file.
Append the following lines to the end of the file. Then, save and close the file.
<The public IP address of your ECS instance> test1.com <The public IP address of your ECS instance> test2.com -
Return to the Windows desktop and press
Win + R. -
In the Run dialog box, enter cmd and click OK.
-
Run the following command in the command prompt to apply the changes immediately.
ipconfig /flushdns
Verify the results
On your on-premises host, open a web browser to verify that you can access both test websites.
-
Go to
test1.com/test1.php. Thewindows-testpage-1website appears, as shown in the following figure.
-
Go to
test2.com/test2.php. Thewindows-testpage-2website appears, as shown in the following figure.
You have successfully hosted multiple websites. In a real-world scenario, you only need to correctly configure the host name and the physical path for each project to make your websites accessible. If you need to install an SSL certificate, see Install an SSL certificate on an IIS server (Windows).
References
If you want to host multiple websites on a Linux instance, see Configure multiple websites by using the Nginx service.

