Updated on 2024-08-01 GMT+08:00

Building the Website

Requested Cloud Resources

Building Process

Obtaining the Software

  1. WinSCP

    WinSCP is a free and open-source SFTP, FTP, WebDAV and SCP client for Microsoft Windows. It is mainly used to transfer files between a local and a remote computer in a secure manner. Download the required version of WinSCP.

  1. Discuz X3.5 (UTF-8)

    Discuz X3.5 (UTF-8) is used to deploy website applications. Download the software package of the required version from the official website.

    • The recommended English version of Discuz X3.5 (UTF-8) is not free of charge. Refer to the provided page for payment details.
    • The software packages are only used to construct the forum. To deploy a commercial website, download the applications as needed.

Building the Database

Install MySQL.

CentOS 7.2 is used as an example to describe how to install MySQL.

  1. Log in to ECS discuz01 remotely and enter the username and password.
  2. Install MySQL.

    wget -i -c 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 --nogpgcheck

Configure MySQL.

  1. Start and enable MySQL.

    systemctl start mysqld

    systemctl enable mysqld

  2. Query the running status of MySQL.

    systemctl status mysqld.service

    Information similar to the following is displayed:

    # systemctl status mysqld.service
    ● mysqld.service - MySQL Server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
       Active: active (running) since Mon 2021-08-23 10:54:55 CST; 7s ago
         Docs: man:mysqld(8)
               http://dev.mysql.com/doc/refman/en/using-systemd.html
     Main PID: 7873 (mysqld)
       CGroup: /system.slice/mysqld.service
               └─7873 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
    
    Aug 23 10:54:49 ecs-adc3-420652-aed6 systemd[1]: Starting MySQL Server...
    Aug 23 10:54:55 ecs-adc3-420652-aed6 systemd[1]: Started MySQL Server.
  3. Obtain the password of user root, which was automatically set during MySQL installation:

    grep 'temporary password' /var/log/mysqld.log

    Information similar to the following is displayed:
    2021-08-16T11:33:37.790533Z 1 [Note] A temporary password is generated for root@localhost: ;8nPd29lhs,k
  4. Harden MySQL.

    mysql_secure_installation

    Securing the MySQL server deployment.
    
    Enter password for user root:    #Enter the obtained password of user root.
    The existing password for the user account root has expired. Please set a new password.
    
    New password:  #Enter the new password.
    
    Re-enter new password:   #Enter the new password again.
    The 'validate_password' plugin is installed on the server.
    The subsequent steps will run with the existing configuration of the plugin.
    Using existing password for root.
    
    Estimated strength of the password: 100
    Change the password for root ? ((Press y|Y for Yes, any other key for No) : N   #Asks you whether to change the password of user root. Press N.
    
     ... skipping.
    By default, a MySQL installation has an anonymous user,
    allowing anyone to log into MySQL without having to have
    a user account created for them. This is intended only for
    testing, and to make the installation go a bit smoother.
    You should remove them before moving into a production
    environment.
    
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y   #Asks you whether to remove anonymous users. Press Y.
    Success.
    
    Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.
    
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y   #Asks you whether to forbid remote login of user root. Press Y.
    Success.
    
    By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.
    
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y   #Asks you whether to delete the test database and cancel access permissions to it. Press Y.
     - Dropping test database...
    Success.
    
     - Removing privileges on test database...
    Success.
    
    Reloading the privilege tables will ensure that all changes
    made so far will take effect immediately.
    
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y   #Asks you whether to reload privilege tables. Press Y.
    Success.
    
    All done!
  5. Enter the password of user root to log in to the database.

    mysql -u root -p

  6. Set the MySQL database as the default database.

    use mysql;

  7. Query the user list.

    select host,user from user;

    This command and the following database commands must end with a semicolon (;).

  8. Refresh the user list and allow all IP addresses to access the database.

    update user set host='%' where user='root' LIMIT 1;

  9. Forcibly update the permissions to allow ECSs in the same subnet to access the MySQL database using private IP addresses.

    flush privileges;

  10. Exit the database.

    quit

  11. Restart MySQL.

    systemctl restart mysqld

  12. Enable MySQL to automatically start upon system boot.

    systemctl enable mysqld

  13. Disable the firewall.

    systemctl stop firewalld.service

  14. Check the firewall status.

    systemctl status firewalld

Setting Up the Web Environment

Install the web environment.

  1. Unbind the EIP from ECS discuz01 and bind it to ECS discuz02.

  2. Log in to ECS discuz02 remotely and enter the username and password.
  3. Install MySQL.

    wget -i -c 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 --nogpgcheck

  4. Install the Apache HTTP Server (httpd), PHP FastCGI Process Manager (php-fpm), MySQL client (mysql), and MySQL server (mysql-server).

    yum install -y httpd php php-fpm mysql mysql-server php-mysql

    If the following information is displayed, the installation is successful.
    Complete!
  5. Reinstall the Apache HTTP Server (httpd), PHP FastCGI Process Manager (php-fpm), MySQL client (mysql), and MySQL server (mysql-server).

    yum reinstall -y httpd php php-fpm mysql mysql-server php-mysql

    If the following information is displayed, the installation is successful.
    Complete!

Configure the web environment.

  1. Start httpd.

    service httpd start

  2. Enable httpd to automatically start upon system boot.

    chkconfig httpd on

  3. Start php-fpm.

    service php-fpm start

  4. Enable php-fpm to automatically start upon system boot.

    chkconfig php-fpm on

  5. Disable the firewall.

    systemctl stop firewalld.service

  6. Check the firewall status again.

    systemctl status firewalld

  7. Start MySQL.

    systemctl start mysqld

  8. Enable MySQL to automatically start upon system boot.

    systemctl enable mysqld.service

  9. Enter http://EIP in a browser to query the default page of the ECS.

Deploying the Website Code

  1. Decompress the Discuz_X3.5_SC_UTF8_20231001.zip package to the Discuz_X3.5_SC_UTF8_20231001 folder.
  2. Use WinSCP to upload the upload file in the Discuz_X3.5_SC_UTF8_20231001 folder to the /var/www/html directory on ECS discuz02. For details, see WinSCP documents.
  3. Log in to discuz02 and run the following command to grant the write permission to other users:

    chmod -R 777 /var/www/html

  4. Enter http://Elastic IP address in the address bar of a browser. Follow the installation wizard to install Discuz.
    • The database address if the private IP address of discuz01.
    • The database password is the password of the database administrator's root account configured on discuz01.

Verifying the Website

In the browser address bar, enter http://Elastic IP address/forum.php. If the forum homepage is displayed, the website is successfully built.