You can configure multiple websites on an Elastic Compute Service (ECS) instance to reduce operational costs and facilitate website management, such as updating software, configuring security settings, and backing up data. You can also flexibly adjust resource allocation as the requirements of the websites change. This topic describes how to use Internet Information Services (IIS) to build multiple websites on an ECS instance that runs the Windows Server 2012 R2 64-bit operating system.
Prerequisites
An ECS instance is created. A web environment in which IIS, PHP, and MySQL are installed is deployed on the instance. You can use a Windows image that contains the environment to deploy the environment on the instance. To obtain the image, go to Alibaba Cloud Marketplace.
In this tutorial, IIS is used to build the windows-testpage-1
and windows-testpage-2
websites and configure different domain names on the same port to access the websites.
Create test websites
Connect to the instance on which the web environment is deployed.
For more information, see Connect to a Windows instance by using a password or key.
On the desktop, click This PC and go to the
C:\wwwroot
path in the default root directory.Create the
windows-testpage-1
andwindows-testpage-2
folders.Open the
windows-testpage-1
folder, create the test1.php file in the folder, and then enter the following content in the file:<?php echo "<title>Test-1</title>"; echo "windows-test-1"; ?>
Open the
windows-testpage-2
folder, create the test2.php file in the folder, and then enter the following content in the file:<?php echo "<title>Test-2</title>"; echo "windows-test-2"; ?>
Configure IIS
In the taskbar, click the Server Manager icon .
In the top navigation bar, choose
.In the left-side navigation pane of the IIS Manager window, click the name of the server and then click Sites.
In the Actions section on the right side, click Add Website. Add the
windows-testpage-1
website and click OK.The following figure shows how to configure the website.
Take note of the following parameters:
Site name: Enter
windows-testpage-1
.Application pool: Select DefaultAppPool.
Physical path: Select a physical path for the
windows-testpage-1
website.Host name: Specify the
test1.com
domain name as the hostname.
In the Actions section on the right side, click Add Website. Add the
windows-testpage-2
website and click OK.The following figure shows how to configure the website.
Take note of the following parameters:
Site name: Enter
windows-testpage-2
.Application pool: Select DefaultAppPool.
Physical path: Select a physical path for the
windows-testpage-2
website.Host name: Specify the
test2.com
domain name as the hostname.
The following figure shows that the websites are added.
(Optional) Configure the hosts file on your on-premises host
All information used in this tutorial is only for reference. You must configure IP mappings in the hosts file on your on-premises host. If you use an actual server domain name when you configure the websites, skip this step. In this tutorial, an on-premises physical server that runs a Windows operating system is used.
Go to the
C:\Windows\System32\drivers\etc
directory.Copy the hosts file.
Retain the
hosts - copy
file, which you can use to restore the hosts file to the initial state after the test is complete.Modify the hosts file.
Append the following content to the end of the file, save the file, and then exit the file:
<Public IP address of the ECS instance> test1.com <Public IP address of the ECS instance> test2.com
Go back to the Windows desktop and press
Win+R
.In the Run dialog box, enter cmd and click OK.
At the command prompt, run the following command for the configurations of the hosts file to immediately take effect:
ipconfig /flushdns
Result
You can access the two test websites from a browser on your on-premises computer.
Enter
test1.com/test1.php
in the address bar of the browser and press the Enter key. Thewindows-testpage-1
website is displayed, as shown in the following figure.Enter
test2.com/test2.php
in the address bar of the browser and press the Enter key. Thewindows-testpage-2
website is displayed, as shown in the following figure.
Multiple websites are built. In actual scenarios, you need to only make sure that the domain names and project paths are correctly configured in the configuration files to allow access to the websites. You can install SSL certificates in IIS. For more information, see Install SSL certificates on IIS servers.
References
If you want to deploy multiple websites on a Linux instance, see Use NGINX to configure multiple websites.