You can host multiple websites on a single ECS instance, enabling unified management and resource sharing for small-scale sites, such as multiple WordPress blogs and static web pages.
Prerequisites
- Web environment deployment
- Operating system: In the example provided in this topic, Windows 2022 is used.
- IIS: Internet Information Services (IIS) is a type of server software developed by Microsoft for hosting and providing web services. In the example provided in this topic, IIS 10.0 is used.
- MySQL/MariaDB: A database management system. In the example provided in this topic, MySQL 8.0 is used.
- PHP: A server-side scripting language embedded in HTML documents. In the example provided in this topic, PHP 7.4 is used.
Procedure
This topic describes how to set up two static web pages on an ECS instance running the Windows operating system.
Step 1: Create a static Web page file
- Log in to the Windows instance where a web environment is set up. Learn more.
- Enter the C:\wwwroot folder.
tip
After you install the IIS web server, this folder is created by default as the root directory of the server.
- Create the windows-page-1 and windows-page-2 folders.
- Click the "View" button in the top menu bar, and check "File name extensions".
- In the windows-page-1 folder, create a text file named page1.php.
- Click the "Yes" button in the pop-up window to complete the creation process.
- Open the page1.php file with Notepad, and enter the following content.
- In the windows-page-2 folder, create a text file named page2.php.
- Click the "Yes" button in the pop-up window to complete the creation process.
- Open the page2.php file with Notepad, and enter the following content into it.
Step 2: Create a website
- Click the "Start" icon, and then click the "Server Manager" button.
- In the server manager window, click "Tools > Internet Information Services (IIS) Manager".
- In the left pane of the "Internet Information Services (IIS) Manager" window, select "<Host Name> (e.g., IV-BXJDxxxxx) > Sites". Then, create and configure the site information.
tip
In the example provided in this topic, two test sites and their web content are created for reference only. In actual site deployment scenarios, you need to configure real domain names, hostnames, physical paths, and other related information.
- Click the "Add Website" button.
- In the "Add Website" window, configure information described in the following table.
- Click "OK" to complete the creation.
- Click the "Add Website" button.
- In the "Add Website" window, configure information described in the following table.
- Click "OK" to complete the creation.
Step 3: Configure the local hosts file (optional)
The domain name of the test site created in this topic is not a valid domain name. Other PCs that need to access the test site must configure the IP mapping in their respective hosts file.
tip
If the "Host Name" value you specified when you create a site in the IIS web server is a valid domain name, skip this step.
- Log in to the local PC that needs to access the test site.
tip
In the example provided in this topic, another Windows instance that can access the Internet (not used for hosting a website) is used.
- Go to the C:\Windows\System32\drivers\etc directory.
tip
We recommend that you copy and save the hosts file as a backup. After the test is complete, you can use the backup to restore the hosts file to its original state.
- Open the hosts file with Notepad, and add the following content at the end of the file.
- Save and close the file.
- Click the "Start" icon, and select "Windows Administrative Tools > Command Prompt".
- Execute the following command in the command line to make the hosts configuration take effect immediately.
Step 4: Access the web page
- Log in to the local PC that has the local hosts file configured.
- Access the test web page in the browser and verify whether it can be accessed.
- At this point, multiple websites are set up.
Step 5: Enable HTTPS for the website (optional)
When a user accesses your website over the HTTP protocol, the browser warns the user that the connection is not secure. We recommend that you enable HTTPS secure communication for your website. This ensures encrypted data transmission between users and your website, effectively defending against network hijacking, information leakage, and other threats.