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.
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.
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.
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.
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.
Check the terms of service and click Create Instance
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.
Scroll 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.
After creation, it will be displayed in the cloud disk list of the management console.
We can manage our server through Alibaba Cloud, click on the instance console, and click Remote Connection on the right
Just log in immediately using the default method.
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.
Already known and backed up, continue to expand. We enter 100G and select online expansion.
Next step
Take a look at the suggestions. The console shows expansion, but there is no actual expansion.
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
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
[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.
9. Install and access kod network disk
Next step
Since we have not installed a database, we can choose the database that comes with PHP.
Enter the account password, confirm, and complete the installation.
Log in normally
Test upload, no problem, project runs normally
10. Test snapshot recovery service
Server delete code directory
[root@web01 nginx]# rm -rf /code
The browser accessed the URL and found that it could not be accessed.
Stop an instance
Restore snapshot
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.
11. Mirror based on snapshots
Snapshot console to create custom images
confirm
After the creation is completed, you can view it in the image list and click Create Instance
12. Create web02 server based on the image
Select the same availability zone as web01
No need to assign public IP
Confirm order, sign and place order
13. Unbind the elastic public IP of web01
Example console, unbinding elastic IP
14. Purchase traditional SLB load and bind elastic public IP
For traditional load balancing, pay attention to the region being consistent with the web region.
As configured in the figure, select the private network because we have an elastic IP that can be bound to the load balancing.
Buy it now
Open now, sign and place your order.
Bind our elastic IP
15. Configure the payload certificate and forward it to the backend WEB
Apply for a certificate
After filling in the relevant information, submit it for review
Instance console, monitoring configuration wizard
Add port 443
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.
Add server, add port
Next step, next step, just submit
Configure port 80 and listen on 443. Next step, submit it.
Add 5555 to forward to web01 and 6666 to forward to web02 respectively.
Next step, next step, submit, configure port 6666 to be forwarded to port 22 of web02
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.
[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!
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!