Use PolarDB and ECS to build a portal website (experience)

Experience goal

The scenario will provide an ECS (cloud server) instance with CentOS as the basic environment and a PolarDB database instance that has been created. We will install WordPress on this server to help you quickly build your own cloud blog.

background knowledge

Introduction to PolarDB database
PolarDB is a next-generation relational cloud database developed by Alibaba Cloud. It has three independent engines, which are 100% compatible with MySQL, 100% compatible with PostgreSQL, and highly compatible with Oracle syntax. The storage capacity is up to 100TB, and the single database is at most. It can be expanded to 16 nodes, which is suitable for enterprise diversified database application scenarios.

PolarDB adopts an architecture that separates storage and computing. All computing nodes share a data, providing minute-level configuration upgrades, second-level failure recovery, global data consistency, and free data backup and disaster recovery services. PolarDB not only integrates the stable, reliable, high-performance, and scalable characteristics of commercial databases, but also has the advantages of open source cloud databases that are simple, open, and self-iterative. For example, PolarDB MySQL can increase its performance up to 6 times that of MySQL, while the cost is only 1% of that of commercial databases. /10. Cluster architecture, separation of computing and storage.

Create resources (you can go to the Alibaba Cloud Experience Lab to experience if you have not purchased ECS )

1. On the left side of the page, click the drop-down menu of cloud product resources to view the resources of this experiment.
2. Click the free activation to create the required resources. The resource creation process takes 1~3 minutes. After completing the creation of experimental resources, you can view the created resource information in the cloud product resource list, such as: IP address, user name, and password.

Create a PolarDB database account

Experiencing users
1. Click Cloud Product Resources on the left side of the page> Copy login url with one click.
Insert picture description here

2. Open the browser incognito window (incognito mode), paste the copied url address to the RAM user login interface, and log in to the Alibaba Cloud management console.

Take the Chrome browser as an example, open a new incognito window and log in to the Alibaba Cloud management console.

a.  依次单击更多>打开新的无痕窗口。

Insert picture description here
b. Paste the login url in the address bar to access the RAM user login page

c. At the login user name, enter the sub-user name and click Next.
Insert picture description here
d. Enter the password and click Login to enter the Alibaba Cloud management console. Insert picture description here
Users with a PolarDB account
3. In the left navigation bar of the Alibaba Cloud console homepage, click Products and Services> PolarDB to enter the PolarDB management console.
Insert picture description here

  1. Click the cluster list on the left, and then select the region provided by the cloud product resources. For example: Huadong 2 (Shanghai).
    Insert picture description here
  2. Create a database account.

    a. On the cluster list page, click the cluster ID to enter the cluster details interface.
    Insert picture description here
    b. Click Configuration and Management> Account Management in the left navigation bar.
    c. Click on the top left to create an account.
    Insert picture description here
    d. Refer to the instructions to configure the account information, and then click OK.
    Insert picture description here
    Database account: Enter the database account name, for example: test_user.
    Account type: select a normal account here.
    Password: Set the account password, for example: Password1213.
    Confirm password: Enter the password again.

  3. Create the database.
    a. On the instance details page, click Database Management in the left navigation bar, and then click Create Database.
    Insert picture description here
    b. Refer to the instructions to configure the database information, and then click Create.
    Insert picture description here
    Database (DB) name: Enter the database name, for example: pbootcms.
    Support character set: set to utf8mb4 by default.
    Authorized account: select the database account test_user created in the previous step.
    Account type: The default setting is read-write.
    Remarks: not required. It is used to note the relevant information of the database, which is convenient for subsequent database management, and supports up to 256 characters.
  4. Set the database whitelist.

To connect to the database, you need to set the database whitelist, click [Cluster Whitelist], and then click [Settings] to set the database cluster whitelist.
Insert picture description here
In the whitelist interface, change the default whitelist address 127.0.0.1 to 0.0.0.0/0, and then click [OK] to make the whitelist address effective.
Insert picture description here

Connect to ECS server

1. Open the terminal tool.
Windows: Open a command window.
MAC: Open the command line terminal Terminal.
For Windows users, please check whether the SSH tool is installed in the system. Inspection Method:

Enter the command ssh -V in the terminal.

ssh -V

If the SSH version is displayed, it means it has been installed, as shown in the figure below.
Insert picture description here
If it is not installed, please download and install the OpenSSH tool.

  1. Enter the connection command ssh [username]@[ipaddress] in the terminal.
    You need to replace username and ipaddress with the elastic public IP of the ECS server created in step 1. E.g:
ssh [email protected]

Insert picture description here
The command display results are as follows:
Insert picture description here

  1. Enter yes.

4. After agreeing to continue, you will be prompted to enter the login password. The password is the login password of the ECS of the created cloud service.
Insert picture description here
After successful login, the following information will be displayed.
Insert picture description here

Install LAMP environment

LAMP refers to the environment of Apache, MySQL and PHP running under Linux. Refer to the following operations to install the development environment on the cloud server.
1. On the ECS server, execute the following commands to install the Apache service and its extension packages.

yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql

If a result similar to the following figure is returned, the installation is successful.
Insert picture description here
2. PbootCMS is a CMS system developed using PHP language. Refer to the following operations to install the PHP environment.
Execute the following command to install PHP.

yum -y install php php-mysql gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap

3. Execute the following commands to download and install MySQL.

wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server

4. Execute the following command to start the MySQL database.

systemctl start mysqld

Build a portal website

After completing the environment deployment, refer to the following operations to build a portal website.
1. On the ECS server, execute the following command to install Git.

yum -y install git

2. On the ECS server, execute the following command to download the PbootCMS source file.

cd ~ && git clone https://gitee.com/hnaoyun/PbootCMS.git

3. Execute the following command to copy the installation package to Apache's wwwroot directory.

cp -r PbootCMS/* /var/www/html/

4. Execute the following command to modify the file permissions of the site root directory.

chmod -R a+w /var/www/html

5. Import the initial data of CMS into the database.
Execute the following command to initialize the table structure and data of the database pbootcms.
Note: Before executing the command, please modify the three parameters.

  • For the database connection address (public network address), please refer to the link address section application at the bottom of the cluster details page.
  • test_user is the database account created in step 2.
  • Password1213 The database password created in step 2.
sql_file="/var/www/html/static/backup/sql/"$(ls /var/www/html/static/backup/sql/) &&
mysql -h数据库连接地址 -utest_user -pPassword1213 -Dpbootcms < $sql_file

6. Execute the following commands to modify the CMS system database configuration.
Note: Before executing the command, please replace your database configuration according to the parameter description.

cat > /var/www/html/config/database.php << EOF
<?php
return array(
    'database' => array(
        'type' => 'mysqli', // 数据库连接驱动类型: mysqli,sqlite,pdo_mysql,pdo_sqlite
        'host' => '数据库连接地址', // PolarDB数据库链接地址
        'user' => 'test_user', // PolarDB数据库的用户名
        'passwd' => 'Password1213', // PolarDB数据库的密码
        'port' => '3306', // 数据库端口
        'dbname' => 'pbootcms' //数据库名称
    )
);
EOF

7. Return to the ECS console. On the ECS instance list page, click the created ECS instance ID link to enter the ECS details page.

  1. In the left navigation bar, click the security group of this instance, and then click the ID link of the security group to view the security group configuration.

Make sure that the security group has opened port 80 for access, otherwise you cannot access the built portal website. A security group is a virtual firewall with stateful inspection and packet filtering capabilities and is used to divide security domains in the cloud. By configuring security group rules, you can control the inbound and outbound traffic of one or more ECS instances in the security group.
Insert picture description here

  1. Visit the program.
    Execute the following command to restart the Apache service.
systemctl restart httpd

Enter the public IP address of the cloud server in the browser address bar to enter the portal homepage.

The default access path of the system backend is http://<ECS public network IP address>/admin.php. The default account is admin and the password is 123456.

At this point, you have completed the construction of the portal website, and you can customize the content of the portal website according to the needs of the company.
Insert picture description here

Guess you like

Origin blog.51cto.com/14981263/2639410