[Advanced Operation and Maintenance Knowledge] Use Alibaba Cloud to deploy the kod Kedao cloud network disk project (HTTPS certificate + load balancing + two webs)

This article will introduce to you how to deploy the kod Kedao cloud network disk project. First, use Alibaba Cloud to build a small architecture, including seven layers of load, two web servers, and https certificates, and then build the kod network disk on the web.

Deployment process

1. Web01 purchase creation

First, buy an ECS and customize the purchase. We choose pay-as-you-go, North China 6 Ulanqab, which is cheaper, with random availability zone, 1cpu1g.

7fc86e1576c24b84939922cb748d436b.png

Select CentOS for the image, 7.9 for the version, and select High Efficiency Cloud Disk as the system disk type, 20G, which is cheap. For enterprises, you must choose it based on your needs. After selecting, you can take the next step. Note that the account must not be less than 100 yuan.

ec0d68e391cc4e0ea0fc92550a65e29d.png

Choose not to allocate public IP to the public network, because we have load balancing, and the load balancing can be accessed through the public network. You can check all the protocol ports opened below and continue to the next step.

52dc468efb9442398251e81194e8c237.png For the password, we choose a custom password. The instance name and host name are consistent, fill in web01, and continue to the next step.

a48d669fa16f4682b980fd605b8af7b3.png

 You can add tags, select security groups, etc. You don’t have to do it. Just go to the next step and confirm the order.

a1b253b61a194220bede0537f175d30f.pngCheck the terms of service and click Create Instance2de9a7b0a0814de5825fb9cee1f0819e.png

It prompts that the creation is successful. Click the management console to see the created instance.

2. Add disk to web01

Click the management console of the ECS cloud disk, create a cloud disk, mount it to the ECS instance, select Ulanqab in the same region as web01, select our web01 instance, and choose pay-as-you-go cloud disk payment, which is also a high-efficiency cloud disk That’s it, 40G, confirm the order. 

e9491a4f894f4a09adc9614557b9a1b6.pngScroll down and select Release with Instance, check the service agreement, modify the name, click Confirm Order, confirm creation, and after a while you will be prompted that the cloud disk is created. 

a4446b6014974aac8e2acd3db68bddf4.pngAfter creation, it will be displayed in the cloud disk list of the management console.

687241aa5fcc49389f1a3a63a6f14ac0.png We can manage our server through Alibaba Cloud, click on the instance console, and click Remote Connection on the right

965d863e4cfb4148b1a9b89933b284ad.png

Just log in immediately using the default method. 

f057b79af28647c69e20ab748a9b072a.png

After entering the password to log in, we can use df -h to check the mounting information. If we don't find it, don't panic. In fact, it is already in our web01, so we can mount it manually.

[root@web01 ~]# yum -y install ntfsprogs
[root@web01 ~]# mkfs.ext4 /dev/vdb
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10485760 blocks
524288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2157969408
320 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   
[root@web01 ~]# mount /dev/vdb /mnt
[root@web01 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        461M     0  461M   0% /dev
tmpfs           471M     0  471M   0% /dev/shm
tmpfs           471M  488K  471M   1% /run
tmpfs           471M     0  471M   0% /sys/fs/cgroup
/dev/vda1        20G  2.3G   17G  13% /
tmpfs            95M     0   95M   0% /run/user/0
/dev/vdb         40G   49M   38G   1% /mnt

3. Expand the data disk to 100G

In the cloud disk management console, select Expansion. 

39d5cc3aa64647c48a0164303f6f8d50.png​​​​ Already known and backed up, continue to expand. We enter 100G and select online expansion.

 

b7c87ae84e474cb7ace1134a9c4589e4.png

Next step 

fe00e3cbd049486f8ff475f0297baae4.png  Take a look at the suggestions. The console shows expansion, but there is no actual expansion.

7036d37bf7f144b7b8256bdc9fee04cb.png We connect to the server remotely, manually cancel the mount, create the file system, and then remount it.

[root@web01 ~]# umount /mnt
[root@web01 ~]# mkfs.ext4 /dev/vdb
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

[root@web01 ~]# mount /dev/vdb/ /mnt
[root@web01 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        461M     0  461M   0% /dev
tmpfs           471M     0  471M   0% /dev/shm
tmpfs           471M  560K  471M   1% /run
tmpfs           471M     0  471M   0% /sys/fs/cgroup
/dev/vda1        20G  2.4G   17G  13% /
tmpfs            95M     0   95M   0% /run/user/0
/dev/vdb         99G   61M   94G   1% /mnt
[root@web01 ~]# 

 4. Install nginx on web01

[root@web01 ~]# yum -y install nginx

#删除nginx中的这部分内容,我们自己在conf.d中创建
    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }

[root@web01 nginx]# cat /etc/nginx/conf.d/kod.conf 
server {
        listen 80;
        server_name kod.koten.vip;
	location / {
                root /code/kod;
                index index.php index.html index.htm;
	}
        location ~\.php$ {
                root /code/kod;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;    #需要加这个,不然白屏
	}        
}    
[root@web01 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@web01 ~]# systemctl start nginx
[root@web01 ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

php, because it involves uploading a compressed package, so we need to use xshell to connect. We first configure the elastic public IP to web01, and then unbind it to the load balancer later.

5. Bind the elastic IP on web01

72a308fc091c45909d974fc2a581ef4c.pnga5ad4c5068c6426d9a79efc7e81bbaf1.png

f19f0558089b4a778aa1739f9fb25727.png

d223644831d149f8868b9f0e0c48f336.png

0a0dedd57d464695aab57f76cfe5923f.png

1240a4a34bf1416693a68003dc9ddea5.png

 6. web01 install php

[root@web01 ~]# yum -y install lrzsz
[root@web01 ~]# rz -E

[root@web01 ~]# tar xf php71.tar.gz 
[root@web01 ~]# yum -y localinstall *.rpm
[root@web01 ~]# systemctl start php-fpm.service
[root@web01 ~]# systemctl enable php-fpm.service
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

[root@web01 ~]# cat /etc/php-fpm.d/www.conf    #统一用户
user = nginx
group = nginx

 7. Deploy kod project

Kedaoyun official website, find the Download Now button, right-click and copy the link address 

6c87bb7569a94ae5ae1edee9f13e7540.png

[root@web01 ~]# wget https://static.kodcloud.com/update/download/kodbox.1.38.zip
[root@web01 ~]# yum -y install unzip
[root@web01 ~]# mkdir -p /code/kod
[root@web01 ~]# unzip kodbox.1.38.zip -d /code/kod
[root@web01 ~]# chown -R nginx.nginx /code/kod/

8. Domain name resolution public network IP

The domain name needs to be registered in advance. Enter Cloud Resolution DNS and perform the operations as shown below. Fill in the record value with the elastic IP you just created. 

651cfa243ae840eabc32e8a4bd36c7f7.png

9. Install and access kod network disk

Next step 

73af650ffa97453bb448b767f1c04e7a.png

Since we have not installed a database, we can choose the database that comes with PHP.

a2242aea7c4f4ef3887fc74e8072fb43.png

Enter the account password, confirm, and complete the installation. 

a9661d1b08274446885352952889e106.png

Log in normally

f6aaf6382c4941baac5666146125a101.pngTest upload, no problem, project runs normally 

5a7b4d25eb2049229c661c9da14cacbd.png

10. Test snapshot recovery service

9598b99629994de6907b6b423c0d4dd1.png

d55813fb7396461e98215aaaafa09db4.png 4d2c3640c52c4a36926c3feca24f057f.png

180300e2f6d742d889f0d58d1d169a5b.png

Server delete code directory

[root@web01 nginx]# rm -rf /code

 The browser accessed the URL and found that it could not be accessed.43cfbd83f7e34ff08c9fdad4400c34e4.png

Stop an instance 

 c664777c1ed54e23b10db50ad2f64396.png

77403d2cac234f72b32dd9829cffd331.png

Restore snapshot 

1d28c66095c64638b85c329851c6729d.png

d82203fc766344d580eda64107202b7c.png

Since we have set up nginx and php to start automatically at boot, the business will be automatically restored after the snapshot is restored. 

After the snapshot is restored successfully, the browser will display normally when accessed again.

7d9f82d7ef8e42629cb040156095ad6d.png

11. Mirror based on snapshots

Snapshot console to create custom images

ed0d1f4458cf4c4fbb7afc0755a31f59.png
92fb4643fc1547ea9b9509ed55391221.png

confirm 

f32c8f02ddc94115a5901e749e8fa6e2.png

After the creation is completed, you can view it in the image list and click Create Instance

f3a129dfe895499493adde1427397eda.png

12. Create web02 server based on the image

Select the same availability zone as web01

bdd22287a9884feaa433468cd9bcc59a.png

1d80348f268f4661b16aae34ba7a044d.png

No need to assign public IP

f40942186e4d44b88ceeaac03d3cecba.png

9f640e1c2d2e4abf98f2e66ed7b028d0.png

 8fd01b37da594ea891ea7f954004c2c0.png

Confirm order, sign and place order49627b61c9a94a459de870c6b2001887.png

13. Unbind the elastic public IP of web01

Example console, unbinding elastic IP

b51c31affc9d446e872447df94e830a3.png14. Purchase traditional SLB load and bind elastic public IP

For traditional load balancing, pay attention to the region being consistent with the web region. 

0feedd4c23e2467c949dae80745cad3e.png

As configured in the figure, select the private network because we have an elastic IP that can be bound to the load balancing.

3a37c88492b744a8a6a3d8cf0f3fc963.png

066609b77e4c4d528c5703ba0bd36c10.png

 Buy it now1182b98d485a4d14898a4672bd19ee95.png

Open now, sign and place your order. 

f48070fb38dc40c3a96b9d1e2c394ff1.png

Bind our elastic IP 

ecd1aad16a714e7b9e60d6f7bf8b00a5.png

d8500b0455cc4543bdb4537d3627204b.png

15. Configure the payload certificate and forward it to the backend WEB

Apply for a certificate

d027a30a847b45c9b90a28353979ab95.png

After filling in the relevant information, submit it for reviewfe61f53052b343e1aa709c6a14e1411f.png5e1202c130174976b7b82e67c3152155.png

Instance console, monitoring configuration wizard 

d61dd14fcd764463a20537646d6b79fd.png

Add port 443 7990fb7c027e4124a18a69d917a9ea55.png

 Add and create a certificate. I just applied for it. Be careful not to choose the wrong one. I chose a different domain name here and won’t modify the picture anymore.

2af341dc74da4efd92d8b303a0cb8159.png

Add server, add port 

bf8370df920049e3b0ee9e1160b2fafb.png

Next step, next step, just submit

Configure port 80 and listen on 443. Next step, submit it.

5ee41d03d3a242778e19b599fe9375fe.png

Add 5555 to forward to web01 and 6666 to forward to web02 respectively. 

f971890eb8814124ab14e37eb11096fb.png

16ac1d07ff6b44618d833309c6441d8c.png

11f91ae290ac4ddfacc8f6a20b151f25.png

 Next step, next step, submit, configure port 6666 to be forwarded to port 22 of web02

9bf7b0cde2e645109bb2c4217350adc3.png

db87dc1fe6d742f9ae137ea0323e5d7e.png3df9b2f33a9145439ca8d9bd7dc1bf0e.png

Next step, next step, submit 

17. Abnormal browser access, modify web server configuration file

Browser access keeps spinning in circles because the PHP on our web server does not recognize the https protocol and needs to modify the configuration file on our web.

d7d1989dbeaf48808229dc4df73d010b.png

 

 

[c:\~]$ ssh 8.130.97.32 5555


Connecting to 8.130.97.32:5555...
Connection established.
To escape to local shell, press Ctrl+Alt+].

Last login: Sun Apr 23 20:18:34 2023 from 123.112.17.24

Welcome to Alibaba Cloud Elastic Compute Service !

[root@web01 ~]# cat /etc/nginx/conf.d/kod.conf
server {
        listen 80;
        server_name kod.koten.vip;
	location / {
                root /code/kod;
                index index.php index.html index.htm;
	}
        location ~\.php$ {
                root /code/kod;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
		fastcgi_param HTTPS on;
	}
}
[root@web01 ~]# systemctl restart nginx


[c:\~]$ ssh 8.130.97.32 6666


Connecting to 8.130.97.32:6666...
Connection established.
To escape to local shell, press Ctrl+Alt+].

Last login: Sun Apr 23 18:23:09 2023 from 123.112.17.24

Welcome to Alibaba Cloud Elastic Compute Service !

[root@web02 ~]# cat /etc/nginx/conf.d/kod.conf
server {
        listen 80;
        server_name kod.koten.vip;
	location / {
                root /code/kod;
                index index.php index.html index.htm;
	}
        location ~\.php$ {
                root /code/kod;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
		fastcgi_param HTTPS on;
	}
}
[root@web02 ~]# systemctl restart nginx

Browser access, return to normal, and you're done!a1cbb9c6644342898475610cd5a117c8.png


My name is Koten. I have 10 years of operation and maintenance experience. I continue to share operation and maintenance tips. Thank you for reading and paying attention! 

 

Guess you like

Origin blog.csdn.net/qq_37510195/article/details/130324416