Elastic Cloud Server

Typical website scenarios

2025-11-25 08:38:03

Typical Website Scenarios

For example, in the high-availability scenario of the WordPress site, front-end cloud servers are deployed in different availability zones, and business traffic is distributed through ELB instances, while back-end data is separated into relational databases.

Resource Parameters

Product

Configuration

Availability Zone

VPC

VpcforWebsite

VPC CIDR block 192.168.0.0/16, subnet CIDR block 192.168.1.0/24

ECS

2*s7.large.4 (2-core 8G); CentOS 7.6

Located in Availability Zone 1 and Availability Zone 2

Relational database MySQL

Master-slave 4-core 8G; MySQL 5.7; Ultra high I/O

-

ELB

SLBforWebsite

-

Elastic IP (EIP)

5M bandwidth

-


Site Topology

Procedure

1. Go to Control Center, select Network > VPC, click to create VPC, set the VPC CIDR block to 192.168.0.0/16 and the subnet CIDR block to 192.168.0.0/24.

2. Go to Control Center, select Computing > ECS, click to create cloud server ECS1, select s7.large.4 for the cloud server specification, set the operating system to CentOS 7.6, and select the VPC and subnet created in step 1.

3. Go to Control Center, select Network > Elastic IP, and click to create Elastic IP.

4. Bind the elastic IP to ECS1 in the cloud server console or elastic IP console.

5. Use the remote login function of the console to log in to ECS1 and deploy WordPress.

1) Execute the following command to install Apache and PHP components:

# Install Apache and PHP components

yum install -y httpd php php-mysql php-gd php-imap php-ldap php-odbc php-

pear php-xml php-xmlrpc

# Start Apache service

service httpd start

# Set to start Apache by default at boot

sudo chkconfig httpd on

2) Execute the following command to create the info.php file and verify whether PHP is installed successfully.

vim /var/www/html/info.php

3) Execute the following command to restart the HTTP service.

service httpd restart

4) If you use any node that can access the Internet to visit http://EIP/info.php, you can see that it is running successfully (ensure that the port used by PHP has been released in the security group where the cloud server is located).

5) Execute the following command to uninstall the current version of PHP and install the higher version.

yum list installed | grep php | awk ‘{print $1}’ | xargs yum remove -y

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum install -y php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64

php56w-gd.x86_64 php56w-imap.x86_64 php56w-ldap.x86_64 php56w-

mysql.x86_64 php56w-pdo.x86_64 php56w-odbc.x86_64 php56w-

process.x86_64 php56w-xml.x86_64 php56w-xmlrpc.x86_64

6) Execute the following command to restart the httpd service.

systemctl restart httpd

7) Execute the following command to download and decompress WordPress software package.

mkdir -p /opt/WP

cd /opt/WP

wget https://cn.wordpress.org/latest-zh_CN.tar.gz

tar -xzvf latest-zh_CN.tar.gz

8) Copy the wordpress directory to /var/www/html/ and execute the following command.

cd /var/www/html

cp -rf /opt/WP/wordpress/* /var/www/html/

9) Go to Control Center, select Database > Relational Database MySQL, and create a MySQL database instance.

10) Install MySQL client in ECS1 for creating and accessing MySQL database instances.

yum install mysql

11) Connect to the MySQL database and create a database instance.

mysql -h<IP> -P<HOST> -u<user> -p<password>  

create database <databasename> charset utf8

12) Modify the configuration of the wordpress access database in ECS1.

cd /var/www/html/

vim wp-config.php

To modify the configuration, see the following:

###########

// ** MySQL settings - Specific information comes from the host you are using ** //

/** WordPress name */

define('DB_NAME', 'db_wordpress');

/** MySQL database username */

define('DB_USER', 'user_wordpress');

/** MySQL database password */

define('DB_PASSWORD', 'Hello1234');

/** MySQL server */

define('DB_HOST', '<RDS instance Intranet address, excluding port number>');

/** Default text encoding when creating a data table */

define('DB_CHARSET', 'utf8');

/** Database collation type. Do not change if you are not sure */

define('DB_COLLATE', '');

###########

6. Open the browser and enter http://EIP:port/wp-admin/install.php to access the WordPress site

 

 

7. Refer to Step 5 to apply for ECS2 and complete the configuration. In the process of configuring ECS2, you can reuse the EIP and mount it to ECS2.

8. Go to Control Center, select Network > ELB, create ELB and bind the requested EIP. When using ELB, the EIP will be offloaded from the cloud server and associated to ELB.

9. Execute the following command to perform A/B test on the website and disable the ECS instance, access failure may occur:

10. ab. -n 10 -c 10 -t 30 -C 'cookies=xxx' -v 3 http://IP/wp-admin


oPDe.rUzm46z