All Products
Search
Document Center

Elastic Compute Service:configure multiple websites on a Windows instance

Last Updated:Mar 29, 2024

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

  1. Connect to the instance on which the web environment is deployed.

  2. On the desktop, click This PC and go to the C:\wwwroot path in the default root directory.

  3. Create the windows-testpage-1 and windows-testpage-2 folders.

    wwwroot

  4. 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";
    ?>
  5. 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

  1. In the taskbar, click the Server Manager icon server.

  2. In the top navigation bar, choose Tools > Internet Information Services (IIS) Manager.

  3. In the left-side navigation pane of the IIS Manager window, click the name of the server and then click Sites.

  4. 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.netsite1

    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.

  5. 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.netsite2

    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.result

(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.

  1. Go to the C:\Windows\System32\drivers\etc directory.

  2. 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.

  3. 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
  4. Go back to the Windows desktop and press Win+R.

  5. In the Run dialog box, enter cmd and click OK.

  6. 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. The windows-testpage-1 website is displayed, as shown in the following figure.test1.php

  • Enter test2.com/test2.php in the address bar of the browser and press the Enter key. The windows-testpage-2 website is displayed, as shown in the following figure.test2.php

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 Build multiple websites on a Linux instance.