- Documentation
Elastic Compute Service
Elastic Compute Service
Best Practices
Self-service website creation
Building websites
Building multiple websites
Setting up multiple websites (Linux)
Building multiple websites
Setting up multiple websites (Linux)
Setting up multiple websites (Linux)
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, CentOS 7.6 is used.
- Nginx: A high-performance, lightweight web server that supports HTTP and reverse proxy. In the example provided in this topic, Nginx 1.20.1 is used.
- MySQL/MariaDB: A database management system. In the example provided in this topic, MySQL 14.14 is used.
- PHP: A server-side scripting language embedded in HTML documents. In the example provided in this topic, PHP 7.0.33 is used.
Procedure
This topic describes how to set up two static web pages on an ECS instance running the Linux operating system.
Step 1: Configure Nginx
- Execute the following command to view the path of the Nginx configuration file.
- In the following output, the include configuration item indicates the path of the file.
-
- Execute the following command to enter the configuration file directory.
- Execute the following command to create a new configuration file.
tip
Perform the operation twice to create the configuration files for web page 1 (webtest1) and web page 2 (webtest2), respectively. The following sections use web page 1 (webtest1) as an example.
- Execute the following command to create a new configuration file.
- Press the i key to enter edit mode, and then add the following content.
- Press Esc, enter :wq, and then press the Enter key to save the file and return to the CLI interface.
- Execute the following command to start the Nginx service.
Step 2: Create web pages
- Execute the following command to enter the website root directory of Nginx.
- Create the website root directories for web pages and configure the website information. The name of the root directory must be the same as the name of the website root directory configured in the Nginx configuration file ***.conf in Step 1.
tip
- Perform the operation twice to create web page 1 (webtest1) and web page 2 (webtest2), respectively. The following sections use web page 1 (webtest1) as an example.
- If you want to set up a WordPress blog or other websites, create multiple root directories for websites in the /usr/share/nginx/html/ directory, and deploy each site in its corresponding root directory.
- Create the website root directory for web page 1 (webtest1).
- Go to the website root directory for web page 1 (webtest1).
- Press the i key to enter edit mode, and then enter the following content.
- Press Esc, enter :wq, and then press the Enter key to save the file and return to the CLI interface.
Step 3: Access the web page
- Enter the following address in the local browser to visit web page 1.
- Enter the following address in the local browser to visit web page 2.
Step 4: 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.
Last updated: 2026.06.18 19:52:58