You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
Building multiple websites
Setting up multiple websites (Linux)
Copy page
Download PDF
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​
  • Software versions​
  • 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​
  1. Remotely connect to and log in to the ECS instance. For more information, see Logging in to Linux instances.​
  1. Execute the following command to view the path of the Nginx configuration file.​
  • ​
    cat /etc/nginx/nginx.conf​
    ​
  • In the following output, the include configuration item indicates the path of the file.​
  • ​​​
  1. Execute the following command to enter the configuration file directory.​
  • ​
    cd /etc/nginx/conf.d​
    ​
  1. 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.​
  1. Execute the following command to create a new configuration file.​
  • ​
    vim webtest1.conf​
    ​
  1. Press the i key to enter edit mode, and then add the following content.​
  • ​
    server {​
    listen 80;​
    server_name webtest1.com; #Type the domain name of web page 1. Use the actual server domain name if you perform this step in a production environment.​
    ​
    #charset koi8-r;​
    access_log /var/log/nginx/b.access.log main;​
    ​
    location / {​
    root /usr/share/nginx/html/webtest1; #Type the website root directory of web page 1. Type the project code path if you perform this step in a production environment. The directory is used to store the website information.​
    index index.html index.htm;​
    }​
    ​
    #error_page 404 /404.html;​
    ​
    error_page 500 502 503 504 /50x.html;​
    location = /50x.html {​
    root /usr/share/nginx/html;​
    }​
    }​
    ​
  1. Press Esc, enter :wq, and then press the Enter key to save the file and return to the CLI interface.​
  1. Execute the following command to start the Nginx service.​
  • ​
    systemctl start nginx​
    ​
Step 2: Create web pages​
  1. Execute the following command to enter the website root directory of Nginx.​
  • ​
    cd /usr/share/nginx/html​
    ​
  1. 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.​
  1. Create the website root directory for web page 1 (webtest1).​
  • ​
    mkdir webtest1​
    ​
  1. Go to the website root directory for web page 1 (webtest1).​
  • ​
    cd webtest1​
    ​
  1. Create a test file.​
  • ​
    vim index.html​
    ​
  1. Press the i key to enter edit mode, and then enter the following content.​
  • ​
    webtest1​
    ​
  1. 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​
  1. Enter the following address in the local browser to visit web page 1.​
  • ​
    http://<ECS instance's Elastic IP (EIP)>/webtest1/index.html​
    ​
  1. Enter the following address in the local browser to visit web page 2.​
  • ​
    http://<ECS instance's Elastic IP (EIP)>/webtest2/index.html​
    ​
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.​
To enable HTTPS, you need to deploy an SSL certificate on your website. You can apply for a free SSL certificate in the Volcano Engine Certificate Center. For more information, see Applying for free certificate and Downloading and installing certificate.​
Last updated: 2026.06.18 19:52:58