基于阿里云的 ECS、RDS,将个人博客迁移升级至:Docker(基于预算考虑,最终未实现)、LNMP(CentOS 7.7、Nginx 1.16、MySQL 5.7、PHP 7.4)、HTTPS 的过程

1、基于 Xshell 6 进入 CentOS 服务器中,将网站程序目录压缩打包,执行压缩命令,执行结果如图1

基于 Xshell 6 进入 CentOS 服务器中,将网站程序目录压缩打包,执行压缩命令

图1

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

2、基于 FlashFXP 连接至 FTP 服务器中,将压缩包:shuijingwanwq.com-20191203.zip 下载至本地,如图2

基于 FlashFXP 连接至 FTP 服务器中,将压缩包:shuijingwanwq.com-20191203.zip 下载至本地

图2

3、基于 phpMyAdmin 连接至 MySQL 服务器,导出个人博客所使用的数据库:shuijingwanwq,文件名为:shuijingwanwq.sql,如图3

基于 phpMyAdmin 连接至 MySQL 服务器,导出个人博客所使用的数据库:shuijingwanwq,文件名为:shuijingwanwq.sql

图3

4、在阿里云容器服务中创建集群,如图4、图5、图6、图7

创建虚拟交换机

图4

 

Worker 实例,选择已有实例

图5

 

集群的其他配置

图6

 

创建集群,状态检测皆为通过

图7

5、发现费用严重超出预算(预算仅为4K),即使按照 Master 实例的最低配置,2核4G,一年下来,费用总计也是接近 5 位数了,最终决定继续沿用原生 CentOS,仅重新升级一下硬件配置与软件版本

6、硬件配置上,决定将数据盘扩容,从 10 GiB 扩容至 40 GiB,如图8

硬件配置上,决定将数据盘扩容,从 10 GiB 扩容至 40 GiB

图8

7、扩容后容量 40 GiB,如图9

扩容后容量 40 GiB

图9

8、停止 ECS 实例,如图10

停止 ECS 实例

图10

9、更换操作系统,如图11

更换操作系统

图11

10、更换操作系统,CentOS 7.7 64位,如图12

更换操作系统,CentOS 7.7 64位

图12

11、停止 ECS 实例后,实例磁盘列表中,系统盘更换操作系统后,系统磁盘已经自动初始化。因此,仅需要数据盘重新初始化,如图13

停止 ECS 实例后,实例磁盘列表中,系统盘更换操作系统后,系统磁盘已经自动初始化。因此,仅需要数据盘重新初始化

图13

12、云数据库RDS,数据库类型:MySQL 5.7,其可用区与 ECS 是一致的,如图14

云数据库RDS,数据库类型:MySQL 5.7,其可用区与 ECS 是一致的

图14

13、挂载数据盘,打开网址:https://oneinstack.com/question/how-to-mount-a-data-disc/ ,挂载成功,如图15

挂载数据盘,打开网址:https://oneinstack.com/question/how-to-mount-a-data-disc/ ,挂载成功

图15

[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) 
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、打开网址:https://oneinstack.com/auto/ ,基于 OneinStack 的自动安装,选择了 LNMP,PHP 版本 7.4,复制安装命令,如图16

打开网址:https://oneinstack.com/auto/ ,基于 OneinStack 的自动安装,选择了 LNMP,PHP 版本 7.4,复制安装命令

图16

15、启动 ECS 实例后,基于 Xshell 6 进入 CentOS 服务器中,粘贴执行安装命令,如图17

启动 ECS 实例后,基于 Xshell 6 进入 CentOS 服务器中,粘贴执行安装命令

图17

16、打开网址:http://121.40.248.29 ,其为 ECS 的公网IP:121.40.248.29,参考添加虚拟主机的文档教程,添加虚拟主机:www.shuijingwanwq.com,如图18

打开网址:http://121.40.248.29 ,其为 ECS 的公网IP:121.40.248.29,参考添加虚拟主机的文档教程,添加虚拟主机:www.shuijingwanwq.com

图18

[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
MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD
ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xOTEyMDUwNDQyMThaFw0y
MDAzMDQwNDQyMThaMCAxHjAcBgNVBAMTFXd3dy5zaHVpamluZ3dhbndxLmNvbTCC
ASIwD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WcvirwBM0+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、管理FTP帐号,添加FTP帐号:www.shuijingwanwq.com,如图19

管理FTP帐号,添加FTP帐号:www.shuijingwanwq.com

图19

[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、管理 RDS,创建帐号:shuijingwanwq,如图20

管理 RDS,创建帐号:shuijingwanwq

图20

19、管理 RDS,新建数据库:shuijingwanwq,字符集:utf8mb4,如图21

管理 RDS,新建数据库:shuijingwanwq,字符集:utf8mb4

图21

20、基本信息,设置白名单后才显示内网地址,如图22

基本信息,设置白名单后才显示内网地址

图22

21、添加白名单分组,其值来源于 ECS 的内网IP,如图23

添加白名单分组,其值来源于 ECS 的内网IP

图23

22、基本信息,内网地址已经显示,如图24

基本信息,内网地址已经显示

图24

23、登录数据库,如图25

登录数据库

图25

24、数据方案 – 导入 – 新增任务 – 导入 SQL 文件:shuijingwanwq.sql,如图26

数据方案 - 导入 - 新增任务 - 导入 SQL 文件:shuijingwanwq.sql

图26

25、导入完成, 成功执行SQL数:385,耗时:8412ms,如图27

导入完成, 成功执行SQL数:385,耗时:8412ms

图27

26、刷新数据库,查看表,已经成功导入,如图28

刷新数据库,查看表,已经成功导入

图28

27、编辑文件:wp-config.php,将 MySQL 主机 的值调整为:RDS 的内网地址,其他配置不变,如图29

编辑文件:wp-config.php,将 MySQL 主机 的值调整为:RDS 的内网地址,其他配置不变

图29

28、基于 FlashFXP ,在站点管理器中新建站点,如图30

基于 FlashFXP ,在站点管理器中新建站点

图30

29、基于 FlashFXP ,连接至 FTP 服务器中,将解压后的程序文件上传,如图31

基于 FlashFXP ,连接至 FTP 服务器中,将解压后的程序文件上传

图31

30、打开网址:shuijingwanwq.com, 以测试是否自动跳转至 www.shuijingwanwq.com,最终打开网址:https://www.shuijingwanwq.com/ ,符合预期,且已经支持 HTTPS,如图32

打开网址:shuijingwanwq.com, 以测试是否自动跳转至 www.shuijingwanwq.com,最终打开网址:https://www.shuijingwanwq.com/ ,符合预期,且已经支持 HTTPS

图32

31、之前由于 PHP 的版本:5.4.15,导致程序不能够升级至:WordPress 5.3,因为其要求的 PHP 的版本为:5.6.20,如图33

之前由于 PHP 的版本:5.4.15,导致程序不能够升级至:WordPress 5.3,因为其要求的 PHP 的版本为:5.6.20

图33

32、现在 PHP 的版本:7.4.0,现在已经可以正常升级,如图34

现在 PHP 的版本:7.4.0,现在已经可以正常升级

图34

33、WordPress更新,您使用的WordPress是最新版本。 将来的安全更新将被自动安装。插件、主题、翻译均为最新版本。如图35

WordPress更新,您使用的WordPress是最新版本。 将来的安全更新将被自动安装。插件、主题、翻译均为最新版本。

图35

原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/181430.html

(0)
上一篇 2021年10月31日
下一篇 2021年10月31日

相关推荐

发表回复

登录后才能评论