# 一.概览

# 1.已经处理

  • 数据表 ddl 备份
  • Vue 前端备份
  • Vue 后端备份
  • 登录服务器后快捷部署脚本看一下
  • 个人目录备份 kwan
  • Nginx 配置备份
  • 图片备份,提交到 gitcode
  • 数据库数据备份-4 号晚上再搞一份

# 二.软件安装

# 1.重装系统后

重装系统后,需要在本地电脑执行如下命令,不然 ssh 连接不成功

#43.139.90.182服务器的ip
ssh-keygen -R 117.72.73.118
1
2

# 2.安装 nvm

#nvm下载地址
https://github.com/nvm-sh/nvm/releases/tag/v0.39.2

#上传到服务器
scp  /Users/qinyingjie/Downloads/nvm-0.39.2.tar.gz root@117.72.42.89:/kwan/software

#进入到软件目录
cd /kwan/software

#价压
tar -zxvf nvm-0.39.2.tar.gz

#移动文件夹
mv nvm-0.39.2 /usr/local/nvm/

#进入文件夹
cd /usr/local/nvm/

#进入文件目录
cd /etc/profile.d/

#编辑文件
vim nvm.sh

#执行文件
sh ./nvm.sh

#查看版本
nvm --version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

nvm.sh 中的内容如下

#!/usr/bin/env bash
export NVM_DIR="/usr/local/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
1
2
3

# 3.安装 node

#列出node的版本
nvm ls-remote

#选择安装指定版本
nvm install 16.18.1

#查看node的版本
node -v

#查看npm的版本
npm -v
1
2
3
4
5
6
7
8
9
10
11

18x 以上版本的 node 需要执行下列指令

#windows系统
set NODE_OPTIONS=--openssl-legacy-provider
#macOS系统
export NODE_OPTIONS=--openssl-legacy-provider
1
2
3
4

# 4.安装 git

sudo yum install git
1

# 5.安装 mysql

参考自己的文章 docker 安装 mysql

# 6.安装 chainlit

参考自己的文章-ai 模块下的 chainlit

# 四.图片 Img

# 1.img 地址

/kwan/blogimg
1

# 2.Git 处理

git pull

git add .

git commit -m 'add'

git push
1
2
3
4
5
6
7

# 3.配置文件

#配置文件地址
/Users/qinyingjie/Documents/typora/blog_upload.json

#进入目录
cd /Users/qinyingjie/Documents/typora
1
2
3
4
5
{
  "Gbolg": {
    "url": "https://www.qinyingjie.top",
    "path": "/blogImg/{fullName}",
    "uploadPath": "/kwan/blogimg/{fullName}",
    "host": "43.139.90.182",
    "port": "22",
    "username": "root",
    "password": "xxx"
  }
}

1
2
3
4
5
6
7
8
9
10
11
12

# 4.修改链接

https://www.qinyingjie.top/blogImg/image-20231010113303262.png
https://qinyingjie.top/new-space/kwan/image-20231103134444486.png

https://www.qinyingjie.top/blogImg  -->   https://qinyingjie.top/blogimg
1
2
3
4
https://qinyingjie.top/new-space/kwan/image-20231103134444486.png
https://qinyingjie.top/new-space/kwan/image-20231103134444486.png

https://qinyingjie.top/blogimg  -->  https://qinyingjie.top/blogimg
1
2
3
4

# 五.nginx

# 1.安装 nginx

#安装相关依赖
sudo yum install epel-release

#安装nginx
sudo yum install nginx
1
2
3
4
5

# 2.常用命令

#启动nginx
sudo systemctl start nginx

#开启nginx
sudo systemctl enable nginx

#重启nginx
sudo systemctl restart nginx

#查看nginx状态
sudo systemctl status nginx
1
2
3
4
5
6
7
8
9
10
11

# 3.目录

/etc/nginx
1

# 4.html

/usr/local/nginx/html
1

# 5.配置文件

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    upstream open-api-blog{
     server 127.0.0.1:8080;
    }
    server {
        listen       80;
	    server_name    www.qinyingjie.top;
        root         /usr/share/nginx/html;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
	       root   html;
    	   index  index.html index.htm;
	       proxy_pass http://127.0.0.1:8080/;
       	}

	    location ~ .*\.(gif|jpg|jpeg|png|jfif|webp)$ {
	         root  /kwan/;
                 autoindex    on ;
        }

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

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

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

# 6.验证 nginx

#验证
/usr/sbin/nginx -t

#加载配置文件
/usr/sbin/nginx -s reload
1
2
3
4
5

# 7.错误日志

tail -f  /var/log/nginx/error.log
1

# 六.blog

# 1.目录

#创建目录
mkdir /kwan

#进入目录
cd /kwan

#拉取代码
git clone  https://gitcode.net/qyj19920704/blog.git
1
2
3
4
5
6
7
8

# 2.部署脚本

#进入目录
cd  /kwan

#创建脚本文件
vim startup-blog.sh
1
2
3
4
5

startup-blog.sh 的内容如下

#打印进程id
echo `ps -ef | grep /kwan/blog/node_modules | grep -v grep | awk '{print $2}'`

#杀掉进程
kill -9  `ps -ef | grep /kwan/blog/node_modules | grep -v grep | awk '{print $2}'`

#进入博客目录
cd /kwan/blog

#设置合并规则
git config pull.rebase false

#拉取代码
git pull

#编译
#npm install

#运行前端代码
nohup  npm run docs:dev >/dev/null 2>&1 & exit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# 3.服务器执行

startup-blog.sh

cd /kwan
sh startup-blog.sh
1
2

# 4.验证服务

ps -ef | grep /kwan/blog/node_modules
1

# 5.访问服务

https://qinyingjie.top:8080/
1

# 七.vue 项目

# 1.服务器脚本

登录服务器后可以直接执行的脚本

end-vue-startup.sh

cd /kwan/chatbot-vue
sh end-startup.sh
1
2

front-vue-startup.sh

cd /kwan/chatbot-vue
sh front-startup.sh
1
2

/kwan/chatbot-vue 文件下结构

drwxr-xr-x 2 root root  70 1030 11:49 end   #文件夹
-rwxr-xr-x 1 root root 179 1027 00:38 end-startup.sh
drwxr-xr-x 3 root root  28 818 09:02 front  #文件夹
-rwxrwxrwx 1 root root 127 107 16:37 front-startup.sh
1
2
3
4

# 2.前端文件夹

front-startup.sh

cd /kwan/chatbot-vue/front/vue-kwan-admin
git pull
yes | cp -r /kwan/chatbot-vue/front/vue-kwan-admin/dist/* /home/nginx/html/
1
2
3

/kwan/chatbot-vue/front

git clone https://gitcode.net/qyj19920704/vue-kwan-admin.git
1

# 3.后端文件夹

end-startup.sh

cd /kwan/chatbot-vue/end

docker build -t chatbox-vue-8888 .

docker rm -f chatbox-vue-8888

docker run -d -p 8888:8888 --restart=always  --name chatbox-vue-8888 chatbox-vue-8888
1
2
3
4
5
6
7

Dockerfile

FROM openjdk:8
VOLUME /tmp
ENV TZ=Asia/Shanghai
ADD vue-springboot-kwan-0.0.1-SNAPSHOT.jar  app.jar
EXPOSE 8888
ENTRYPOINT ["java","-jar","/app.jar"]
1
2
3
4
5
6

vue-springboot-kwan-0.0.1-SNAPSHOT.jar

# 4.nginx 镜像和文件

#搜索一个nginx镜像
docker search nginx

#下载一个nginx镜像
docker pull nginx:latest

#启动一个nginx
docker run -d --name nginx01 -p 8077:8077  nginx:latest

#把文件拷贝出来
docker cp nginx01:/etc/nginx/nginx.conf /home/nginx/
docker cp nginx01:/etc/nginx/conf.d /home/nginx/conf/
docker cp nginx01:/usr/share/nginx/html /home/nginx/html
docker cp nginx01:/var/log/nginx/ /home/nginx/logs/

#删除nginx镜像
docker rm -f nginx01
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# 5.配置 nginx

#进入配置文件
cd  /home/nginx/conf

#编辑配置文件
vim default.conf
1
2
3
4
5

nginx 的配置

server {
    listen       8077;
    listen  [::]:8077;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    location /api{
          proxy_pass  https://qinyingjie.top:8888;
       }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# 6.启动 nginx

#启动nginx
docker run -d --name nginx -p 8077:8077 --restart=always -v /home/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/nginx/logs:/var/log/nginx -v /home/nginx/html:/usr/share/nginx/html -v /home/nginx/conf:/etc/nginx/conf.d --privileged=true -e TZ=Asia/Shanghai nginx:latest

#关闭
docker rm -f nginx

#查看启动日志,错误可以从这里看
docker logs nginx

#查看日志
docker logs -f --tail 500 nginx
1
2
3
4
5
6
7
8
9
10
11

# 7.访问验证

https://qinyingjie.top:8077
1
上次更新: 11/26/2024, 10:00:43 PM