Skip to content

Windows 客户部署实操手册

生成日期:2026-04-25
用途说明:用于在一台全新 Windows 电脑上部署RuoYi Office 企业管理一体化平台,包含后端、PC 前端、移动端 H5、MySQL、Redis、Nginx、数据库连接工具、文件本地存储配置和安全策略。

一、部署目标

本手册适用于客户现场只有一台 Windows 电脑的场景。部署完成后,客户通过浏览器访问:

  • PC 管理端:http://客户电脑IP/web/
  • 移动端 H5:http://客户电脑IP/app/
  • 后端接口:由 Nginx 代理,不直接对外暴露

推荐架构如下:

text
客户浏览器 / 手机浏览器
          |
          | 只访问 80 或 443
          v
Windows 电脑上的 Nginx
    |-- /web       -> PC 前端静态文件
    |-- /app       -> 移动端 H5 静态文件
    |-- /admin-api -> 反向代理到 127.0.0.1:48080
          |
          v
Spring Boot 后端 yudao-server.jar
          |
          |-- MySQL 8.0,本机访问
          |-- Redis,本机访问
          |-- 本地文件目录 C:\ruoyi-office\upload

生产环境建议只对客户局域网或公网开放 80/4434808033066379 不要对外开放。

二、部署前确认

2.1 服务器配置建议

项目最低配置推荐配置
CPU4 核8 核
内存8 GB16 GB
磁盘100 GB200 GB 以上 SSD
系统Windows 10/11 专业版或 Windows Server 2019+Windows Server 2022

2.2 需要准备的安装包

全新电脑需要下载安装以下软件:

软件推荐版本下载地址用途
JDK21 LTS 或 17 LTShttps://adoptium.net/temurin/releases/运行后端
MySQL8.0 Communityhttps://dev.mysql.com/downloads/installer/数据库
Redis 兼容服务Memurai Developer 或 Redis for Windowshttps://www.memurai.com/get-memurai / https://github.com/tporadowski/redis/releases缓存
NginxWindows Stable 版https://nginx.org/en/download.html静态文件和反向代理
数据库工具DBeaver Communityhttps://dbeaver.io/download/连接和导入数据库
NSSM最新版https://nssm.cc/download把后端和 Nginx 注册为 Windows 服务
7-Zip最新版https://www.7-zip.org/解压安装包

如果需要在客户电脑上构建代码,还需要安装:

软件推荐版本下载地址
Git2.xhttps://git-scm.com/download/win
Maven3.9.xhttps://maven.apache.org/download.cgi
Node.js20 LTS 或 22 LTShttps://nodejs.org/en/download
pnpm10.xhttps://pnpm.io/installation

推荐做法是在开发机或构建机提前打包,只把以下产物拷贝到客户电脑:

  • 后端:yudao-server.jar
  • PC 前端:ruoyi-office-vben/apps/web-antd/dist
  • 移动端 H5:ruoyi-office-uniapp/dist/build/h5
  • 数据库全量 SQL 和增量 SQL

三、目录规划

在客户电脑创建统一目录,后续手册都按这个目录说明:

powershell
New-Item -ItemType Directory -Force C:\ruoyi-office
New-Item -ItemType Directory -Force C:\ruoyi-office\app
New-Item -ItemType Directory -Force C:\ruoyi-office\app\backend
New-Item -ItemType Directory -Force C:\ruoyi-office\app\web
New-Item -ItemType Directory -Force C:\ruoyi-office\app\app
New-Item -ItemType Directory -Force C:\ruoyi-office\conf
New-Item -ItemType Directory -Force C:\ruoyi-office\logs
New-Item -ItemType Directory -Force C:\ruoyi-office\upload
New-Item -ItemType Directory -Force C:\ruoyi-office\backup
New-Item -ItemType Directory -Force C:\ruoyi-office\sql
New-Item -ItemType Directory -Force C:\ruoyi-office\soft

目录用途:

目录用途
C:\ruoyi-office\app\backend存放后端 JAR
C:\ruoyi-office\app\web存放 PC 前端 dist 文件
C:\ruoyi-office\app\app存放移动端 H5 文件,对应访问路径 /app/
C:\ruoyi-office\conf存放后端外部配置、Nginx 配置备份
C:\ruoyi-office\logs存放后端运行日志
C:\ruoyi-office\upload本地文件上传目录
C:\ruoyi-office\backup数据库和文件备份
C:\ruoyi-office\sql存放初始化 SQL、增量 SQL
C:\ruoyi-office\soft存放安装包

四、安装 JDK

4.1 下载并安装

  1. 打开 https://adoptium.net/temurin/releases/
  2. 选择:
    • Operating System:Windows
    • Architecture:x64
    • Package Type:JDK
    • Version:21 - LTS,如客户环境要求也可选择 17 - LTS
  3. 下载 .msi 安装包。
  4. 双击安装,建议勾选:
    • Set JAVA_HOME variable
    • Add to PATH

4.2 验证

打开新的 PowerShell:

powershell
java -version

能看到 1721 版本号即成功。

如果提示找不到 java,检查环境变量:

powershell
echo $env:JAVA_HOME
echo $env:Path

五、安装 MySQL

5.1 安装 MySQL Server

  1. 打开 https://dev.mysql.com/downloads/installer/
  2. 下载 MySQL Installer for Windows
  3. 安装类型建议选择 Server only。如果希望同时安装图形工具,可选择 Developer Default
  4. 配置类型选择 Server Computer
  5. 端口保持 3306
  6. 认证方式选择 Use Strong Password Encryption
  7. 设置 root 密码,务必记录到客户交付文档中,不要使用弱密码。
  8. Windows Service 名称保持 MySQL80,勾选开机自启。

密码建议:

text
长度至少 12 位,包含大小写字母、数字、特殊字符。
示例仅用于说明:YuQing@20260425_DB!

5.2 安装数据库连接工具

推荐安装 DBeaver Community:

  1. 下载:https://dbeaver.io/download/
  2. 安装后打开 DBeaver。
  3. 新建连接,选择 MySQL
  4. 连接信息:
    • Host:127.0.0.1
    • Port:3306
    • Database:先留空
    • Username:root
    • Password:安装 MySQL 时设置的密码
  5. 点击测试连接。首次连接会提示下载驱动,允许下载即可。 ![[Pasted image 20260425151849.png]]
  6. 驱动属性 allowPublicKeyRetrieval=true

5.3 创建业务数据库

打开 DBeaver 的 SQL 编辑器,执行:

sql
CREATE DATABASE IF NOT EXISTS `ruoyi-office`
  DEFAULT CHARACTER SET utf8mb4
  COLLATE utf8mb4_unicode_ci;

也可以用 PowerShell 执行:

powershell
& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -uroot -p -e "CREATE DATABASE IF NOT EXISTS `ruoyi-office` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"

5.4 导入数据库

把数据库全量 SQL 和增量 SQL 放到:

text
C:\ruoyi-office\sql

导入全量 SQL:

powershell
cmd /c '"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -uroot -p ruoyi-office < "C:\ruoyi-office\sql\schema_20260423_154300.sql"'

如果有增量 SQL,按日期从早到晚依次导入:

powershell
cmd /c '"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -uroot -p ruoyi-office < "C:\ruoyi-office\sql\static_data_20260423_154300.sql"'

导入完成后验证:

powershell
& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -uroot -p -e "USE `ruoyi-office`; SHOW TABLES;"

能看到 system_userssystem_roleinfra_file_config 等表即成功。

5.5 MySQL 安全建议

客户部署在单机时,MySQL 只允许本机访问即可:

  1. 打开 MySQL 配置文件,常见路径:
    • C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
  2. [mysqld] 下增加或确认:
ini
bind-address=127.0.0.1
  1. 重启 MySQL 服务:
powershell
Restart-Service MySQL80
  1. Windows 防火墙不要开放 3306

六、安装 Redis

Windows 没有官方 Redis Server。客户现场推荐使用 Memurai Developer,兼容 Redis 协议,安装和服务管理更适合 Windows。

6.1 方案 A:安装 Memurai

  1. 打开 https://www.memurai.com/get-memurai
  2. 下载 Windows 安装包。
  3. 按默认步骤安装。
  4. 安装完成后会创建 Windows 服务。

验证:

powershell
Get-Service *memurai*

如需设置密码,编辑 Memurai 配置文件,通常在安装目录或 C:\Program Files\Memurai 下,增加:

text
bind 127.0.0.1
requirepass YuQing@2026_Redis!

然后重启服务。

6.2 方案 B:Redis for Windows

也可使用社区维护版本:

  1. 打开 https://github.com/tporadowski/redis/releases
  2. 下载 .msi.zip
  3. 安装或解压到 C:\Redis
  4. 修改 redis.windows.confredis.windows-server.conf
text
bind 127.0.0.1
port 6379
requirepass YuQing@2026_Redis!

注册为服务:

powershell
cd C:\Program Files\Redis
.\redis-server.exe --service-install redis.windows.conf --service-name Redis --loglevel notice
Start-Service Redis

验证:

powershell
cd C:\Redis
.\redis-cli.exe -a YuQing@2026_Redis! ping

返回 PONG 即成功。

6.3 Redis客户端下载

https://github.com/qishibo/AnotherRedisDesktopManager/releases

6.4 Redis 安全建议

  • 6379 不对外开放。
  • 必须绑定 127.0.0.1
  • 建议设置强密码。
  • 后端配置里 Redis 密码要和这里一致。

七、安装 Nginx

7.1 下载和解压

  1. 打开 https://nginx.org/en/download.html
  2. 下载 Windows 版 stable 包,例如 nginx-1.26.x.zip
  3. 解压到:
text
C:\nginx

确保最终结构类似:

text
C:\nginx\nginx.exe
C:\nginx\conf\nginx.conf
C:\nginx\html

7.2 验证 Nginx

powershell
cd C:\nginx
.\nginx.exe -t
.\nginx.exe

浏览器访问:

text
http://127.0.0.1

出现 Nginx 欢迎页即成功。

停止 Nginx:

powershell
cd C:\nginx
.\nginx.exe -s stop

八、准备部署产物

8.1 推荐:开发机提前构建

后端构建命令:

bash
cd ruoyi-office
mvn clean package "-Dmaven.test.skip=true" "-Dskip.repackage=true" -pl yudao-server -am -Pboot

构建产物:

text
ruoyi-office/yudao-server/target/yudao-server.jar

PC 前端构建命令:

bash
cd ruoyi-office-vben
pnpm install
pnpm -r --filter "./packages/**" --filter "./internal/**" build
cd apps/web-antd
pnpm build

构建产物:

text
ruoyi-office-vben/apps/web-antd/dist

移动端 H5 构建命令:

bash
cd ruoyi-office-uniapp
pnpm install
pnpm build:h5

构建产物:

text
ruoyi-office-uniapp/dist/build/h5

8.2 复制到客户电脑

复制后端 JAR:

text
C:\ruoyi-office\app\backend\yudao-server.jar

复制 PC 前端 dist 内的所有文件到:

text
C:\ruoyi-office\app\web

复制移动端 H5 的所有文件到:

text
C:\ruoyi-office\app\app

注意不是把 disth5 文件夹整体再套一层,而是目录内应该直接能看到:

text
index.html
assets
static

九、后端配置

后端 JAR 已包含 application-prod.yaml,现场部署建议使用外部配置文件覆盖敏感信息。

新建:

text
C:\ruoyi-office\conf\application-prod.yaml

写入以下内容,并把密码替换为现场真实密码:

yaml
server:
  port: 48080

spring:
  datasource:
    dynamic:
      datasource:
        master:
          url: jdbc:mysql://127.0.0.1:3306/ruoyi-office?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
          username: root
          password: YuQing@2026_DB!
        slave:
          lazy: true
          url: jdbc:mysql://127.0.0.1:3306/ruoyi-office?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
          username: root
          password: YuQing@2026_DB!
  data:
    redis:
      host: 127.0.0.1
      port: 6379
      database: 0
      password: YuQing@2026_Redis!

logging:
  file:
    name: C:/ruoyi-office/logs/yudao-server.log

management:
  endpoints:
    web:
      exposure:
        include: health,info

yudao:
  access-log:
    enable: false
  demo: false

说明:

  • MySQL、Redis 都使用 127.0.0.1,避免后端走外网或局域网地址。
  • management.endpoints.web.exposure.include 建议生产只开放 health,info
  • 日志放到 C:\ruoyi-office\logs,方便排查。

十、启动后端

10.1 手动启动验证

先用手动方式验证配置是否正确:

powershell
cd C:\ruoyi-office\app\backend
java -Xms1024m -Xmx4096m -jar yudao-server.jar --spring.profiles.active=prod --spring.config.additional-location=file:C:/ruoyi-office/conf/

等待 30 到 90 秒,看到类似信息表示启动成功:

text
Started YudaoServerApplication

再打开一个 PowerShell 验证:

powershell
Invoke-WebRequest http://127.0.0.1:48080/actuator/health

返回 UP 即成功。

验证成功后,回到运行后端的窗口,按 Ctrl + C 停止。

10.2 使用 NSSM 注册后端服务

解压 NSSM 到:

text
C:\nssm

注册服务:

powershell
C:\nssm\win64\nssm.exe install YuQingBackend

在弹出的窗口中填写:

Application:

字段
PathC:\Program Files\Eclipse Adoptium\jdk-21...\bin\java.exe
Startup directoryC:\ruoyi-office\app\backend
Arguments-Xms512m -Xmx2048m -jar yudao-server.jar --spring.profiles.active=prod --spring.config.additional-location=file:C:/ruoyi-office/conf/

I/O:

字段
OutputC:\ruoyi-office\logs\backend-service.out.log
ErrorC:\ruoyi-office\logs\backend-service.err.log

Details:

字段
Display nameYuQing Backend
Startup type``

点击 Install service

启动服务:

powershell
Start-Service YuQingBackend
Get-Service YuQingBackend

常用命令:

powershell
Restart-Service YuQingBackend
Stop-Service YuQingBackend
C:\nssm\win64\nssm.exe edit YuQingBackend

查看日志:

powershell
Get-Content C:\ruoyi-office\logs\yudao-server.log -Tail 100 -Wait

十一、Nginx 配置

11.1 写入配置

备份原配置:

powershell
Copy-Item C:\nginx\conf\nginx.conf C:\nginx\conf\nginx.conf.bak

编辑:

text
C:\nginx\conf\nginx.conf

替换为以下配置。请把 server_name 改成客户电脑 IP 或客户域名。

nginx
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;
    client_max_body_size 200m;

    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_comp_level 6;
    gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/x-javascript image/svg+xml;

    server {
        listen       80;
        server_name  客户电脑IP;
        charset      utf-8;

        # 不带结尾斜杠时跳转,避免访问 /web 返回 404
        location = /web {
            return 301 /web/;
        }

        # PC 管理端,访问 http://客户电脑IP/web/
        location /web/ {
            alias C:/ruoyi-office/app/web/;
            index index.html;
            try_files $uri $uri/ /web/index.html;
        }

        # PC 前端静态资源缓存
        location ~* ^/web/(.+)\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
            root C:/ruoyi-office/app;
            expires 30d;
            add_header Cache-Control "public, immutable";
            access_log off;
        }

        # 不带结尾斜杠时跳转,避免访问 /app 返回 404
        location = /app {
            return 301 /app/;
        }

        # 移动端 H5,访问 http://客户电脑IP/app/
        location ^~ /app/ {
            root C:/ruoyi-office/app;
            index index.html;
            try_files $uri $uri/ /app/index.html;
        }

        # 移动端 H5 静态资源缓存
        location ~* ^/app/(.+)\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
            root C:/ruoyi-office/app;
            expires 30d;
            add_header Cache-Control "public, immutable";
            access_log off;
        }

        # 后端 API 反向代理
        location /admin-api/ {
            proxy_pass http://127.0.0.1:48080/admin-api/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;

            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";

            proxy_connect_timeout 60s;
            proxy_send_timeout 60s;
            proxy_read_timeout 60s;
        }

        # 文件访问、下载、预览等后端接口同样走后端代理
        location /admin-api/infra/file/ {
            proxy_pass http://127.0.0.1:48080/admin-api/infra/file/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_read_timeout 300s;
        }

        # 根路径默认跳到 PC 管理端
        location = / {
            return 302 /web/;
        }
    }
}

11.2 检查并启动

powershell
cd C:\nginx
.\nginx.exe -t
.\nginx.exe

# 或强制重启
cd C:\nginx
.\nginx.exe -t
taskkill /F /IM nginx.exe
.\nginx.exe

如果已经启动过,重载配置:

powershell
cd C:\nginx
.\nginx.exe -s reload

浏览器验证:

text
http://127.0.0.1/web/
http://127.0.0.1/app/

11.3 注册 Nginx 为 Windows 服务

powershell
C:\nssm\win64\nssm.exe install YuQingNginx

Application:

字段
PathC:\nginx\nginx.exe
Startup directoryC:\nginx
Arguments

Details:

字段
Display nameYuQing Nginx
Startup typeAutomatic

点击 Install service 后启动:

powershell
Start-Service YuQingNginx
Get-Service YuQingNginx

注意:如果用 NSSM 托管 Nginx,日常重载仍可执行:

powershell
cd C:\nginx
.\nginx.exe -s reload

十二、前端和 H5 路径确认

12.1 PC 前端

当前 PC 前端生产配置:

text
base: /web/
接口地址: /admin-api

因此 Nginx 必须保证:

  • /web/ 指向 C:\ruoyi-office\app\web
  • /admin-api/ 代理到 http://127.0.0.1:48080/admin-api/

12.2 移动端 H5

当前移动端 H5 生产配置:

text
VITE_APP_PUBLIC_BASE=/app/
VITE_SERVER_BASEURL=/admin-api

因此 Nginx 必须保证:

  • /app/ 指向 C:\ruoyi-office\app\app
  • /admin-api/ 同样代理到后端

如果将来修改为域名部署,例如 https://oa.customer.com/web/https://oa.customer.com/app/,不需要改前端接口地址,只要 Nginx 保持 /admin-api/ 代理即可。

十三、文件保存策略设置为本地

截图中的位置是:

text
基础设施 -> 文件管理 -> 文件配置

客户现场单机部署时,文件保存策略必须设置为本地,避免仍使用示例的 S3、MinIO、七牛等配置。

13.1 准备本地文件目录

确认目录存在:

powershell
New-Item -ItemType Directory -Force C:\ruoyi-office\upload

给运行后端服务的 Windows 用户授予读写权限。如果后端用本机管理员账号运行,一般无需额外处理;如果使用专用用户,请在目录属性里给该用户 读取写入修改 权限。

13.2 后台界面配置

登录 PC 管理端:

text
http://客户电脑IP/web/

进入:

text
基础设施 -> 文件管理 -> 文件配置

找到或新增本地存储配置,按以下值设置:

字段建议值
配置名本地存储(客户现场)
存储器本地存储
基础路径 / basePathC:\ruoyi-office\upload
自定义域名 / domainhttp://客户电脑IP
主配置
备注Windows 客户现场本地文件存储

如果已有截图中类似 本地存储(示例) 的配置,也可以直接编辑它:

  1. 点击 编辑
  2. 把路径改为 C:\ruoyi-office\upload
  3. 把域名改为客户实际访问地址,例如 http://192.168.1.10
  4. 保存。
  5. 点击该行的 主配置,确保主配置列显示为

13.3 上传验证

在系统中找一个上传附件的位置,上传一张小图片或 PDF。

验证:

  1. 页面提示上传成功。
  2. C:\ruoyi-office\upload 下生成文件。
  3. 点击预览或下载可以正常访问。

如果上传成功但无法预览,优先检查文件配置的 domain 是否和客户访问地址一致。

十四、安全策略和端口开放

14.1 端口规划

端口服务是否对外开放说明
80Nginx HTTP客户访问入口
443Nginx HTTPS推荐有证书时开放
48080后端服务只允许本机 Nginx 访问
3306MySQL只允许本机访问
6379Redis只允许本机访问
3389远程桌面谨慎只允许管理员固定 IP

14.2 Windows 防火墙配置

以管理员身份打开 PowerShell。

开放 HTTP:

powershell
New-NetFirewallRule -DisplayName "YuQing HTTP 80" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow

如果配置 HTTPS,再开放 443:

powershell
New-NetFirewallRule -DisplayName "YuQing HTTPS 443" -Direction Inbound -Protocol TCP -LocalPort 443 -Action Allow

明确阻止后端端口对外访问:

powershell
New-NetFirewallRule -DisplayName "Block YuQing Backend 48080" -Direction Inbound -Protocol TCP -LocalPort 48080 -Action Block

明确阻止 MySQL 和 Redis 对外访问:

powershell
New-NetFirewallRule -DisplayName "Block MySQL 3306" -Direction Inbound -Protocol TCP -LocalPort 3306 -Action Block
New-NetFirewallRule -DisplayName "Block Redis 6379" -Direction Inbound -Protocol TCP -LocalPort 6379 -Action Block

查看规则:

powershell
Get-NetFirewallRule | Where-Object DisplayName -like "*YuQing*"

14.3 账号和密码安全

上线前必须修改:

  • MySQL root 密码。
  • Redis 密码。
  • 系统默认 admin 密码。
  • Druid 监控账号密码,如果开放使用。
  • 所有示例配置中的第三方密钥、测试账号。

生产环境不建议:

  • 对外暴露 /actuator 全部端点。
  • 对外暴露 Druid 控制台。
  • 使用 admin/admin123
  • 使用公网 IP 直接开放 3306637948080

十五、完整启动顺序

每次服务器重启后,服务应自动启动。首次部署或手动排查时,按以下顺序启动:

  1. MySQL
  2. Redis 或 Memurai
  3. 后端 YuQingBackend
  4. Nginx YuQingNginx

PowerShell 命令:

powershell
Start-Service MySQL80
Start-Service Redis
Start-Service YuQingBackend
Start-Service YuQingNginx

如果使用 Memurai,把 Redis 替换成实际服务名:

powershell
Get-Service *memurai*

十六、上线验收清单

16.1 本机验收

在客户电脑浏览器访问:

text
http://127.0.0.1/web/
http://127.0.0.1/app/

后端健康检查:

powershell
Invoke-WebRequest http://127.0.0.1:48080/actuator/health

16.2 局域网验收

在另一台电脑或手机上访问:

text
http://客户电脑IP/web/
http://客户电脑IP/app/

如果本机能访问,局域网不能访问,重点检查:

  • Windows 防火墙是否开放 80
  • 客户电脑 IP 是否正确。
  • 客户网络是否禁止设备互访。
  • Nginx 是否正在运行。

16.3 功能验收

至少验证:

  • PC 管理端可以打开登录页。
  • 管理员账号可以登录。
  • 菜单和列表可以正常加载。
  • 移动端 H5 可以打开。
  • 上传文件成功,并保存到 C:\ruoyi-office\upload
  • 刷新 /web/ 下任意页面不会 404。
  • 刷新 /app/ 下任意页面不会 404。

十七、日常更新

17.1 更新后端

  1. 备份当前 JAR:
powershell
Copy-Item C:\ruoyi-office\app\backend\yudao-server.jar C:\ruoyi-office\backup\yudao-server-$(Get-Date -Format yyyyMMddHHmmss).jar
  1. 停止后端:
powershell
Stop-Service YuQingBackend
  1. 替换新的 JAR 到:
text
C:\ruoyi-office\app\backend\yudao-server.jar
  1. 启动后端:
powershell
Start-Service YuQingBackend
  1. 查看日志:
powershell
Get-Content C:\ruoyi-office\logs\yudao-server.log -Tail 100 -Wait

17.2 更新 PC 前端

  1. 备份旧文件:
powershell
Compress-Archive C:\ruoyi-office\app\web\* C:\ruoyi-office\backup\web-$(Get-Date -Format yyyyMMddHHmmss).zip
  1. 清空旧文件:
powershell
Remove-Item C:\ruoyi-office\app\web\* -Recurse -Force
  1. 复制新的 PC 前端 dist 内容到:
text
C:\ruoyi-office\app\web
  1. 重载 Nginx:
powershell
cd C:\nginx
.\nginx.exe -s reload

17.3 更新移动端 H5

  1. 备份旧文件:
powershell
Compress-Archive C:\ruoyi-office\app\app\* C:\ruoyi-office\backup\h5-$(Get-Date -Format yyyyMMddHHmmss).zip
  1. 清空旧文件:
powershell
Remove-Item C:\ruoyi-office\app\app\* -Recurse -Force
  1. 复制新的 H5 构建产物内容到:
text
C:\ruoyi-office\app\app
  1. 重载 Nginx:
powershell
cd C:\nginx
.\nginx.exe -s reload

17.4 更新数据库

更新数据库前必须备份。

备份:

powershell
& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqldump.exe" -uroot -p --single-transaction --routines --triggers ruoyi-office > C:\ruoyi-office\backup\ruoyi-office-$(Get-Date -Format yyyyMMddHHmmss).sql

执行增量:

powershell
& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -uroot -p ruoyi-office < C:\ruoyi-office\sql\增量文件.sql

执行后重启后端:

powershell
Restart-Service YuQingBackend

十八、备份策略

18.1 数据库备份

建议每天备份一次数据库,至少保留 7 到 30 天。

创建脚本:

text
C:\ruoyi-office\backup\backup-db.ps1

内容:

powershell
$date = Get-Date -Format "yyyyMMddHHmmss"
$backupDir = "C:\ruoyi-office\backup"
$mysqlDump = "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqldump.exe"

& $mysqlDump -uroot -p"请替换为数据库密码" --single-transaction --routines --triggers ruoyi-office > "$backupDir\ruoyi-office-$date.sql"

可以用 Windows 任务计划程序每天凌晨执行。

18.2 上传文件备份

备份上传目录:

powershell
Compress-Archive C:\ruoyi-office\upload\* C:\ruoyi-office\backup\upload-$(Get-Date -Format yyyyMMddHHmmss).zip

建议把数据库备份和上传文件备份复制到另一块硬盘、NAS 或客户指定备份服务器,避免单机硬盘故障导致数据全部丢失。

十九、常见问题

Q1:访问 /web//app/ 返回 404?

检查:

powershell
Test-Path C:\ruoyi-office\app\web\index.html
Test-Path C:\ruoyi-office\app\app\index.html
cd C:\nginx
.\nginx.exe -t

确认 Nginx 的 alias 路径以 / 结尾:

nginx
alias C:/ruoyi-office/app/web/;
root C:/ruoyi-office/app;

Q2:页面能打开,但接口 502?

说明 Nginx 没连上后端。

检查后端:

powershell
Get-Service YuQingBackend
Invoke-WebRequest http://127.0.0.1:48080/actuator/health
Get-Content C:\ruoyi-office\logs\yudao-server.log -Tail 200

常见原因:

  • 后端服务未启动。
  • MySQL 密码不正确。
  • Redis 密码不正确。
  • 48080 被其他程序占用。

查看端口占用:

powershell
netstat -ano | findstr :48080

Q3:后端启动失败,提示数据库连接失败?

检查:

  • MySQL 服务是否运行:Get-Service MySQL80
  • 数据库是否存在:ruoyi-office
  • C:\ruoyi-office\conf\application-prod.yaml 中数据库密码是否正确
  • MySQL 是否允许本机连接

手动测试:

powershell
& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -uroot -p -h127.0.0.1 -P3306 ruoyi-office

Q4:后端启动失败,提示 Redis 连接失败?

检查:

powershell
Get-Service Redis
cd C:\Redis
.\redis-cli.exe -a YuQing@2026_Redis! ping

如果使用 Memurai,请使用 Memurai 对应的 CLI 或查看服务日志。

Q5:上传文件失败?

重点检查:

  • 文件配置是否设置为本地存储。
  • 主配置是否为本地存储。
  • basePath 是否为 C:\ruoyi-office\upload
  • 后端服务运行用户是否有目录写入权限。
  • Nginx client_max_body_size 是否足够大。

Q6:上传成功但文件无法下载或预览?

重点检查文件配置里的 domain

text
http://客户电脑IP

不要配置成:

text
http://127.0.0.1:48080

客户浏览器访问时需要使用客户能访问到的地址。

Q7:局域网其他电脑访问不了?

检查:

powershell
ipconfig
Get-NetFirewallRule | Where-Object DisplayName -like "*YuQing*"

确认:

  • 客户访问的是正确 IP。
  • Windows 防火墙已开放 80
  • Nginx 正在运行。
  • 客户网络允许互访。

Q8:Nginx 修改配置后不生效?

执行:

powershell
cd C:\nginx
.\nginx.exe -t
.\nginx.exe -s reload

如果提示端口被占用:

powershell
netstat -ano | findstr :80

根据 PID 在任务管理器中确认占用程序。

二十、交付信息记录表

部署完成后,建议填写并交给客户保存:

项目内容
客户访问地址http://________/web/
移动端 H5 地址http://________/app/
服务器 IP________
Windows 登录账号________
MySQL 账号root
MySQL 密码________
Redis 密码________
系统管理员账号________
系统管理员密码________
后端服务名YuQingBackend
Nginx 服务名YuQingNginx
上传文件目录C:\ruoyi-office\upload
数据库备份目录C:\ruoyi-office\backup
部署日期________
部署人员________
联系我们

获取报价、演示和二开方案

微信咨询二维码

微信咨询

17156169080

添加时备注「RuoYi Office」

在线体验商业版