没有不值得去解决的问题,也没有不值得去学习的技术!

Migrating a Personal Blog on Alibaba Cloud ECS and RDS to LNMP and HTTPS

WordPress update: You are using the latest version of WordPress. Future security updates will be installed automatically. Plugins, themes, and translations are all up to date.

1. Log in to the CentOS server using Xshell 6, compress and package the website program directory, and execute the compression command. The execution result is shown in Figure 1.

Log in to the CentOS server using Xshell 6, compress and package the website program directory, and execute the compression command
Figure 1
Bash

cd /data/wwwroot/shuijingwanwq.com
zip -r shuijingwanwq.com-20191203.zip /data/wwwroot/shuijingwanwq.com

2. Connect to the FTP server using FlashFXP and download the archive: shuijingwanwq.com-20191203.zip to your local machine, as shown in Figure 2.

Connect to the FTP server using FlashFXP and download the archive: shuijingwanwq.com-20191203.zip to your local machine
Figure 2

3. Connect to the MySQL server using phpMyAdmin and export the database used by the personal blog: shuijingwanwq, with the file name: shuijingwanwq.sql, as shown in Figure 3.

Connect to the MySQL server using phpMyAdmin and export the database used by the personal blog: shuijingwanwq, with the file name: shuijingwanwq.sql
Figure 3

4. Create a cluster in Alibaba Cloud Container Service, as shown in Figures 4, 5, 6, and 7.

Create a virtual switch
Figure 4

 

Worker instance, select an existing instance
Figure 5

 

Other cluster configurations
Figure 6

 

Create cluster, all status checks passed
Figure 7

5. I found that the cost far exceeded the budget (the budget was only 4K). Even with the minimum configuration for the Master instance, 2 cores and 4GB RAM, the total annual cost would approach five figures. I ultimately decided to continue using the native CentOS and only upgrade the hardware configuration and software versions.

6. For the hardware configuration, I decided to expand the data disk from 10 GiB to 40 GiB, as shown in Figure 8.

For the hardware configuration, decided to expand the data disk from 10 GiB to 40 GiB
Figure 8

7. The capacity is 40 GiB after expansion, as shown in Figure 9.

Capacity is 40 GiB after expansion
Figure 9

8. Stop the ECS instance, as shown in Figure 10.

Stop the ECS instance
Figure 10

9. Replace the operating system, as shown in Figure 11.

Replace the operating system
Figure 11

10. Replace the operating system with CentOS 7.7 64-bit, as shown in Figure 12.

Replace the operating system with CentOS 7.7 64-bit
Figure 12

11. After stopping the ECS instance, in the instance disk list, the system disk has been automatically initialized after the operating system replacement. Therefore, only the data disk needs to be reinitialized, as shown in Figure 13.

After stopping the ECS instance, in the instance disk list, the system disk has been automatically initialized after the operating system replacement. Therefore, only the data disk needs to be reinitialized
Figure 13

12. ApsaraDB RDS, database type: MySQL 5.7. Its zone is the same as the ECS, as shown in Figure 14.

ApsaraDB RDS, database type: MySQL 5.7. Its zone is the same as the ECS
Figure 14

13. Mount the data disk by opening the URL: https://oneinstack.com/question/how-to-mount-a-data-disc/ . The mount was successful, as shown in Figure 15.

Mount the data disk by opening the URL: https://oneinstack.com/question/how-to-mount-a-data-disc/ , mount successful
Figure 15
Plaintext

[root@iZ23wv7v5ggZ ~]# wget http://mirrors.linuxeye.com/scripts/auto_fdisk.sh
--2019-12-05 11:29:45--  http://mirrors.linuxeye.com/scripts/auto_fdisk.sh
Resolving mirrors.linuxeye.com (mirrors.linuxeye.com)... 61.160.200.234
Connecting to mirrors.linuxeye.com (mirrors.linuxeye.com)|61.160.200.234|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5598 (5.5K) [text/x-json]
Saving to: ‘auto_fdisk.sh’

100%[=======================================================================================>] 5,598       --.-K/s   in 0.006s  

2019-12-05 11:29:45 (970 KB/s) - ‘auto_fdisk.sh’ saved [5598/5598]

[root@iZ23wv7v5ggZ ~]# chmod +x ./auto_fdisk.sh
[root@iZ23wv7v5ggZ ~]# ./auto_fdisk.sh

#######################################################################
#       OneinStack for CentOS/RedHat 5+ Debian 6+ and Ubuntu 12+      #
#                             Auto fdisk                              #
#       For more information please visit http://oneinstack.com       #
#######################################################################

Step 1.No lock file, begin to create lock file and continue

Step 2.Begin to check free disk
You have a free disk, Now will fdisk it and mount it
This system have free disk :
/dev/vdb

Step 3.Begin to fdisk free disk

Step 4.Begin to make directory

Please enter a location to mount (Default directory: /data): 

Step 5.Begin to write configuration to /etc/fstab and mount device

Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        486M     0  486M   0% /dev
tmpfs           496M     0  496M   0% /dev/shm
tmpfs           496M  436K  496M   1% /run
tmpfs           496M     0  496M   0% /sys/fs/cgroup
/dev/vda1        20G  1.8G   17G  10% /
tmpfs           100M     0  100M   0% /run/user/0
/dev/vdb1        40G   49M   38G   1% /data

14. Open the URL: https://oneinstack.com/auto/ . For the OneinStack automatic installation, I selected LNMP and PHP version 7.4, then copied the installation command, as shown in Figure 16.

Open the URL: https://oneinstack.com/auto/ , for the OneinStack automatic installation, selected LNMP and PHP version 7.4, copied the installation command
Figure 16

15. After starting the ECS instance, log in to the CentOS server using Xshell 6, paste and execute the installation command, as shown in Figure 17.

After starting the ECS instance, log in to the CentOS server using Xshell 6, paste and execute the installation command
Figure 17

16. Open the URL: http://121.40.248.29 , which is the public IP of the ECS: 121.40.248.29. Referring to the documentation tutorial for adding a virtual host, add the virtual host: www.shuijingwanwq.com, as shown in Figure 18.

Open the URL: http://121.40.248.29 , which is the public IP of the ECS: 121.40.248.29. Referring to the documentation tutorial for adding a virtual host, add the virtual host: www.shuijingwanwq.com
Figure 18
Plaintext

[root@iZ23wv7v5ggZ ~]# ls
auto_fdisk.sh  oneinstack  oneinstack-full.tar.gz
[root@iZ23wv7v5ggZ ~]# cd oneinstack
[root@iZ23wv7v5ggZ oneinstack]# ./vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 6+ Debian 8+ and Ubuntu 14+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
	1. Use HTTP Only
	2. Use your own SSL Certificate and Key
	3. Use Let's Encrypt to Create SSL Certificate and Key
	q. Exit
Please input the correct option: 3

Please input domain(example: www.example.com): www.shuijingwanwq.com
domain=www.shuijingwanwq.com

Please input the directory for the domain:www.shuijingwanwq.com :
(Default directory: /data/wwwroot/www.shuijingwanwq.com): 
Virtual Host Directory=/data/wwwroot/www.shuijingwanwq.com

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: y

Type domainname or IP(example: example.com other.example.com): shuijingwanwq.com
domain list=shuijingwanwq.com

Do you want to redirect from shuijingwanwq.com to www.shuijingwanwq.com? [y/n]: y

Do you want to redirect all HTTP requests to HTTPS? [y/n]: y
[Thu Dec  5 13:42:04 CST 2019] Create account key ok.
[Thu Dec  5 13:42:04 CST 2019] Registering account
[Thu Dec  5 13:42:06 CST 2019] Registered
[Thu Dec  5 13:42:06 CST 2019] ACCOUNT_THUMBPRINT='YjoQ78tWzIgLHz3s7fhC7IoepTPjD3tKvXNrLwE417w'
[Thu Dec  5 13:42:06 CST 2019] Creating domain key
[Thu Dec  5 13:42:06 CST 2019] The domain key is here: /root/.acme.sh/www.shuijingwanwq.com/www.shuijingwanwq.com.key
[Thu Dec  5 13:42:06 CST 2019] Multi domain='DNS:www.shuijingwanwq.com,DNS:shuijingwanwq.com'
[Thu Dec  5 13:42:06 CST 2019] Getting domain auth token for each domain
[Thu Dec  5 13:42:09 CST 2019] Getting webroot for domain='www.shuijingwanwq.com'
[Thu Dec  5 13:42:09 CST 2019] Getting webroot for domain='shuijingwanwq.com'
[Thu Dec  5 13:42:10 CST 2019] Verifying: www.shuijingwanwq.com
[Thu Dec  5 13:42:13 CST 2019] Success
[Thu Dec  5 13:42:13 CST 2019] Verifying: shuijingwanwq.com
[Thu Dec  5 13:42:17 CST 2019] Success
[Thu Dec  5 13:42:17 CST 2019] Verify finished, start to sign.
[Thu Dec  5 13:42:17 CST 2019] Lets finalize the order, Le_OrderFinalize: https://acme-v02.api.letsencrypt.org/acme/finalize/73156074/1675742914
[Thu Dec  5 13:42:19 CST 2019] Download cert, Le_LinkCert: https://acme-v02.api.letsencrypt.org/acme/cert/03c589a531a1436b28e9162b53022c7e4bdd
[Thu Dec  5 13:42:20 CST 2019] Cert success.
-----BEGIN CERTIFICATE-----
MIIFdTCCBF2gAwIBAgISA8WJpTGhQ2so6RYrUwIsfkvdMA0GCSqGSIb3DQEBCwUA
MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMw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QSB8gDwAHYAb1N2rDHwMRnYmQCkURX/dxUcEdkCwQAp
Bo2yCJo32RMAAAFu1JSaBQAABAMARzBFAiEAjyN2kk8UHD+chH/Lpb0m0Ve0ORc6
tEwbx0/1rt0bBBYCIF3JMCisI70bNmHpIWcvirwBM0+1t6Yyy5b+xA65v6/BAHYA
B7dcG+V9aP/xsMYdIxXHuuZXfFeUt2ruvGE6GmnTohwAAAFu1JSZ/gAABAMARzBF
AiB4wGj9xD+Yj4Szu5yAb6/266KPSX2QxIL1J6YSyOSq+AIhAIZe0ii2cOvUn9Wb
gE2RmVXOKohPp8cmqR9OfRK7icBUMA0GCSqGSIb3DQEBCwUAA4IBAQB+8IQ0C4Zj
nDHy69nQ9hv2DnpWA20v8efPIr+mxmmESGZo3DlZBkzbuWgFB3ObpX2rYhzVm9gK
awDUZ4RI4CBG2JvzDhib7/C9OBSLQ4ZWxwPtwrGygACslBZ5t1hb531SawFd3PKf
CZBAa80oF52D//M2l0yoaCzoCcckih8t3MH1ehKQQMvYGaEjMuhtcBm1Z830YWzY
jmdIasyeSn5ErrgKW3asBgBnhO9U6fngot8HqUFU3stj0mAs5b2rumAHhgH1cvh3
AfXkQSnFh+MLErarwW92oxM7dDIiT3AHY4RAXM/uBMNTTMu8n01g9RW2zZo+a7wB
zyCDzi3YL8Bp
-----END CERTIFICATE-----
[Thu Dec  5 13:42:20 CST 2019] Your cert is in  /root/.acme.sh/www.shuijingwanwq.com/www.shuijingwanwq.com.cer 
[Thu Dec  5 13:42:20 CST 2019] Your cert key is in  /root/.acme.sh/www.shuijingwanwq.com/www.shuijingwanwq.com.key 
[Thu Dec  5 13:42:20 CST 2019] The intermediate CA cert is in  /root/.acme.sh/www.shuijingwanwq.com/ca.cer 
[Thu Dec  5 13:42:20 CST 2019] And the full chain certs is there:  /root/.acme.sh/www.shuijingwanwq.com/fullchain.cer 

Do you want to add hotlink protection? [y/n]: n

Allow Rewrite rule? [y/n]: y

Please input the rewrite of programme :
wordpress,opencart,magento2,drupal,joomla,codeigniter,laravel
thinkphp,pathinfo,discuz,typecho,ecshop,nextcloud,zblog,whmcs rewrite was exist.
(Default rewrite: other): wordpress
You choose rewrite=wordpress

Allow Nginx/Tengine/OpenResty access_log? [y/n]: y
You access log file=/data/wwwlogs/www.shuijingwanwq.com_nginx.log

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reload Nginx......

#######################################################################
#       OneinStack for CentOS/RedHat 6+ Debian 8+ and Ubuntu 14+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  www.shuijingwanwq.com
Virtualhost conf:             /usr/local/nginx/conf/vhost/www.shuijingwanwq.com.conf
Directory of:                 /data/wwwroot/www.shuijingwanwq.com
Rewrite rule:                 /usr/local/nginx/conf/rewrite/wordpress.conf
Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/www.shuijingwanwq.com.crt
SSL Private Key:              /usr/local/nginx/conf/ssl/www.shuijingwanwq.com.key

17. Manage FTP accounts and add the FTP account: www.shuijingwanwq.com, as shown in Figure 19.

Manage FTP accounts, add the FTP account: www.shuijingwanwq.com
Figure 19
Plaintext

[root@iZ23wv7v5ggZ oneinstack]# ./pureftpd_vhost.sh

#######################################################################
#       OneinStack for CentOS/RedHat 6+ Debian 8+ and Ubuntu 14+      #
#                 FTP virtual user account management                 #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
	1. UserAdd
	2. UserMod
	3. UserPasswd
	4. UserDel
	5. ListAllUser
	6. ShowUser
	q. Exit
Please input the correct option: 5
User was not existed! 

What Are You Doing?
	1. UserAdd
	2. UserMod
	3. UserPasswd
	4. UserDel
	5. ListAllUser
	6. ShowUser
	q. Exit
Please input the correct option: 1

Please input a username: www.shuijingwanwq.com

Please input the password: 

Please input the directory(Default directory: /data/wwwroot): /data/wwwroot/www.shuijingwanwq.com
Password: 
Enter it again: 
#####################################

[www.shuijingwanwq.com] create successful! 

You user name is : www.shuijingwanwq.com
You Password is : 
You directory is : /data/wwwroot/www.shuijingwanwq.com


What Are You Doing?
	1. UserAdd
	2. UserMod
	3. UserPasswd
	4. UserDel
	5. ListAllUser
	6. ShowUser
	q. Exit
Please input the correct option: q
[root@iZ23wv7v5ggZ oneinstack]# 


18. Manage RDS and create the account: shuijingwanwq, as shown in Figure 20.

Manage RDS, create the account: shuijingwanwq
Figure 20

19. Manage RDS and create a new database: shuijingwanwq, character set: utf8mb4, as shown in Figure 21.

Manage RDS, create a new database: shuijingwanwq, character set: utf8mb4
Figure 21

20. Basic information: the intranet address is displayed only after setting the whitelist, as shown in Figure 22.

Basic information: the intranet address is displayed only after setting the whitelist
Figure 22

21. Add a whitelist group, with its value derived from the ECS intranet IP, as shown in Figure 23.

Add a whitelist group, with its value derived from the ECS intranet IP
Figure 23

22. Basic information: the intranet address is now displayed, as shown in Figure 24.

Basic information: the intranet address is now displayed
Figure 24

23. Log in to the database, as shown in Figure 25.

Log in to the database
Figure 25

24. Data solution – Import – New Task – Import SQL file: shuijingwanwq.sql, as shown in Figure 26.

Data solution - Import - New Task - Import SQL file: shuijingwanwq.sql
Figure 26

25. Import completed. Number of successfully executed SQL statements: 385, time elapsed: 8412ms, as shown in Figure 27.

Import completed. Number of successfully executed SQL statements: 385, time elapsed: 8412ms
Figure 27

26. Refresh the database and view the tables; the import was successful, as shown in Figure 28.

Refresh the database and view the tables; the import was successful
Figure 28

27. Edit the file: wp-config.php to change the MySQL host value to the RDS intranet address, keeping other configurations unchanged, as shown in Figure 29.

Edit the file: wp-config.php to change the MySQL host value to the RDS intranet address, keeping other configurations unchanged
Figure 29

28. Using FlashFXP, create a new site in the Site Manager, as shown in Figure 30.

Using FlashFXP, create a new site in the Site Manager
Figure 30

29. Connect to the FTP server using FlashFXP and upload the extracted program files, as shown in Figure 31.

Connect to the FTP server using FlashFXP and upload the extracted program files
Figure 31

30. Open the URL: shuijingwanwq.com to test whether it automatically redirects to www.shuijingwanwq.com. Ultimately, the URL https://www.shuijingwanwq.com/ is opened, which meets expectations and already supports HTTPS, as shown in Figure 32.

Open the URL: shuijingwanwq.com to test whether it automatically redirects to www.shuijingwanwq.com. Ultimately, the URL https://www.shuijingwanwq.com/ is opened, which meets expectations and already supports HTTPS
Figure 32

31. Previously, because the PHP version was 5.4.15, the program could not be upgraded to WordPress 5.3, which requires PHP version 5.6.20, as shown in Figure 33.

Previously, because the PHP version was 5.4.15, the program could not be upgraded to WordPress 5.3, which requires PHP version 5.6.20
Figure 33

32. Now the PHP version is 7.4.0, and the upgrade now works properly, as shown in Figure 34.

Now the PHP version is 7.4.0, and the upgrade now works properly
Figure 34

33. WordPress update: You are using the latest version of WordPress. Future security updates will be installed automatically. Plugins, themes, and translations are all up to date, as shown in Figure 35.

WordPress update: You are using the latest version of WordPress. Future security updates will be installed automatically. Plugins, themes, and translations are all up to date.
Figure 35

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系