Windows 客户部署实操手册
生成日期:2026-04-25
用途说明:用于在一台全新 Windows 电脑上部署RuoYi Office 企业管理一体化平台,包含后端、PC 前端、移动端 H5、MySQL、Redis、Nginx、数据库连接工具、文件本地存储配置和安全策略。
一、部署目标
本手册适用于客户现场只有一台 Windows 电脑的场景。部署完成后,客户通过浏览器访问:
- PC 管理端:
http://客户电脑IP/web/ - 移动端 H5:
http://客户电脑IP/app/ - 后端接口:由 Nginx 代理,不直接对外暴露
推荐架构如下:
客户浏览器 / 手机浏览器
|
| 只访问 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/443。48080、3306、6379 不要对外开放。
二、部署前确认
2.1 服务器配置建议
| 项目 | 最低配置 | 推荐配置 |
|---|---|---|
| CPU | 4 核 | 8 核 |
| 内存 | 8 GB | 16 GB |
| 磁盘 | 100 GB | 200 GB 以上 SSD |
| 系统 | Windows 10/11 专业版或 Windows Server 2019+ | Windows Server 2022 |
2.2 需要准备的安装包
全新电脑需要下载安装以下软件:
| 软件 | 推荐版本 | 下载地址 | 用途 |
|---|---|---|---|
| JDK | 21 LTS 或 17 LTS | https://adoptium.net/temurin/releases/ | 运行后端 |
| MySQL | 8.0 Community | https://dev.mysql.com/downloads/installer/ | 数据库 |
| Redis 兼容服务 | Memurai Developer 或 Redis for Windows | https://www.memurai.com/get-memurai / https://github.com/tporadowski/redis/releases | 缓存 |
| Nginx | Windows Stable 版 | https://nginx.org/en/download.html | 静态文件和反向代理 |
| 数据库工具 | DBeaver Community | https://dbeaver.io/download/ | 连接和导入数据库 |
| NSSM | 最新版 | https://nssm.cc/download | 把后端和 Nginx 注册为 Windows 服务 |
| 7-Zip | 最新版 | https://www.7-zip.org/ | 解压安装包 |
如果需要在客户电脑上构建代码,还需要安装:
| 软件 | 推荐版本 | 下载地址 |
|---|---|---|
| Git | 2.x | https://git-scm.com/download/win |
| Maven | 3.9.x | https://maven.apache.org/download.cgi |
| Node.js | 20 LTS 或 22 LTS | https://nodejs.org/en/download |
| pnpm | 10.x | https://pnpm.io/installation |
推荐做法是在开发机或构建机提前打包,只把以下产物拷贝到客户电脑:
- 后端:
yudao-server.jar - PC 前端:
ruoyi-office-vben/apps/web-antd/dist - 移动端 H5:
ruoyi-office-uniapp/dist/build/h5 - 数据库全量 SQL 和增量 SQL
三、目录规划
在客户电脑创建统一目录,后续手册都按这个目录说明:
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 下载并安装
- 打开 https://adoptium.net/temurin/releases/
- 选择:
- Operating System:
Windows - Architecture:
x64 - Package Type:
JDK - Version:
21 - LTS,如客户环境要求也可选择17 - LTS
- Operating System:
- 下载
.msi安装包。 - 双击安装,建议勾选:
Set JAVA_HOME variableAdd to PATH
4.2 验证
打开新的 PowerShell:
java -version能看到 17 或 21 版本号即成功。
如果提示找不到 java,检查环境变量:
echo $env:JAVA_HOME
echo $env:Path五、安装 MySQL
5.1 安装 MySQL Server
- 打开 https://dev.mysql.com/downloads/installer/
- 下载
MySQL Installer for Windows。 - 安装类型建议选择
Server only。如果希望同时安装图形工具,可选择Developer Default。 - 配置类型选择
Server Computer。 - 端口保持
3306。 - 认证方式选择
Use Strong Password Encryption。 - 设置
root密码,务必记录到客户交付文档中,不要使用弱密码。 - Windows Service 名称保持
MySQL80,勾选开机自启。
密码建议:
长度至少 12 位,包含大小写字母、数字、特殊字符。
示例仅用于说明:YuQing@20260425_DB!5.2 安装数据库连接工具
推荐安装 DBeaver Community:
- 下载:https://dbeaver.io/download/
- 安装后打开 DBeaver。
- 新建连接,选择
MySQL。 - 连接信息:
- Host:
127.0.0.1 - Port:
3306 - Database:先留空
- Username:
root - Password:安装 MySQL 时设置的密码
- Host:
- 点击测试连接。首次连接会提示下载驱动,允许下载即可。 ![[Pasted image 20260425151849.png]]
- 驱动属性 allowPublicKeyRetrieval=true
5.3 创建业务数据库
打开 DBeaver 的 SQL 编辑器,执行:
CREATE DATABASE IF NOT EXISTS `ruoyi-office`
DEFAULT CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;也可以用 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 放到:
C:\ruoyi-office\sql导入全量 SQL:
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,按日期从早到晚依次导入:
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"'导入完成后验证:
& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -uroot -p -e "USE `ruoyi-office`; SHOW TABLES;"能看到 system_users、system_role、infra_file_config 等表即成功。
5.5 MySQL 安全建议
客户部署在单机时,MySQL 只允许本机访问即可:
- 打开 MySQL 配置文件,常见路径:
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
- 在
[mysqld]下增加或确认:
bind-address=127.0.0.1- 重启 MySQL 服务:
Restart-Service MySQL80- Windows 防火墙不要开放
3306。
六、安装 Redis
Windows 没有官方 Redis Server。客户现场推荐使用 Memurai Developer,兼容 Redis 协议,安装和服务管理更适合 Windows。
6.1 方案 A:安装 Memurai
- 打开 https://www.memurai.com/get-memurai
- 下载 Windows 安装包。
- 按默认步骤安装。
- 安装完成后会创建 Windows 服务。
验证:
Get-Service *memurai*如需设置密码,编辑 Memurai 配置文件,通常在安装目录或 C:\Program Files\Memurai 下,增加:
bind 127.0.0.1
requirepass YuQing@2026_Redis!然后重启服务。
6.2 方案 B:Redis for Windows
也可使用社区维护版本:
- 打开 https://github.com/tporadowski/redis/releases
- 下载
.msi或.zip。 - 安装或解压到
C:\Redis。 - 修改
redis.windows.conf、redis.windows-server.conf:
bind 127.0.0.1
port 6379
requirepass YuQing@2026_Redis!注册为服务:
cd C:\Program Files\Redis
.\redis-server.exe --service-install redis.windows.conf --service-name Redis --loglevel notice
Start-Service Redis验证:
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 下载和解压
- 打开 https://nginx.org/en/download.html
- 下载 Windows 版 stable 包,例如
nginx-1.26.x.zip。 - 解压到:
C:\nginx确保最终结构类似:
C:\nginx\nginx.exe
C:\nginx\conf\nginx.conf
C:\nginx\html7.2 验证 Nginx
cd C:\nginx
.\nginx.exe -t
.\nginx.exe浏览器访问:
http://127.0.0.1出现 Nginx 欢迎页即成功。
停止 Nginx:
cd C:\nginx
.\nginx.exe -s stop八、准备部署产物
8.1 推荐:开发机提前构建
后端构建命令:
cd ruoyi-office
mvn clean package "-Dmaven.test.skip=true" "-Dskip.repackage=true" -pl yudao-server -am -Pboot构建产物:
ruoyi-office/yudao-server/target/yudao-server.jarPC 前端构建命令:
cd ruoyi-office-vben
pnpm install
pnpm -r --filter "./packages/**" --filter "./internal/**" build
cd apps/web-antd
pnpm build构建产物:
ruoyi-office-vben/apps/web-antd/dist移动端 H5 构建命令:
cd ruoyi-office-uniapp
pnpm install
pnpm build:h5构建产物:
ruoyi-office-uniapp/dist/build/h58.2 复制到客户电脑
复制后端 JAR:
C:\ruoyi-office\app\backend\yudao-server.jar复制 PC 前端 dist 内的所有文件到:
C:\ruoyi-office\app\web复制移动端 H5 的所有文件到:
C:\ruoyi-office\app\app注意不是把 dist 或 h5 文件夹整体再套一层,而是目录内应该直接能看到:
index.html
assets
static九、后端配置
后端 JAR 已包含 application-prod.yaml,现场部署建议使用外部配置文件覆盖敏感信息。
新建:
C:\ruoyi-office\conf\application-prod.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 手动启动验证
先用手动方式验证配置是否正确:
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 秒,看到类似信息表示启动成功:
Started YudaoServerApplication再打开一个 PowerShell 验证:
Invoke-WebRequest http://127.0.0.1:48080/actuator/health返回 UP 即成功。
验证成功后,回到运行后端的窗口,按 Ctrl + C 停止。
10.2 使用 NSSM 注册后端服务
解压 NSSM 到:
C:\nssm注册服务:
C:\nssm\win64\nssm.exe install YuQingBackend在弹出的窗口中填写:
Application:
| 字段 | 值 |
|---|---|
| Path | C:\Program Files\Eclipse Adoptium\jdk-21...\bin\java.exe |
| Startup directory | C:\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:
| 字段 | 值 |
|---|---|
| Output | C:\ruoyi-office\logs\backend-service.out.log |
| Error | C:\ruoyi-office\logs\backend-service.err.log |
Details:
| 字段 | 值 |
|---|---|
| Display name | YuQing Backend |
| Startup type | `` |
点击 Install service。
启动服务:
Start-Service YuQingBackend
Get-Service YuQingBackend常用命令:
Restart-Service YuQingBackend
Stop-Service YuQingBackend
C:\nssm\win64\nssm.exe edit YuQingBackend查看日志:
Get-Content C:\ruoyi-office\logs\yudao-server.log -Tail 100 -Wait十一、Nginx 配置
11.1 写入配置
备份原配置:
Copy-Item C:\nginx\conf\nginx.conf C:\nginx\conf\nginx.conf.bak编辑:
C:\nginx\conf\nginx.conf替换为以下配置。请把 server_name 改成客户电脑 IP 或客户域名。
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 检查并启动
cd C:\nginx
.\nginx.exe -t
.\nginx.exe
# 或强制重启
cd C:\nginx
.\nginx.exe -t
taskkill /F /IM nginx.exe
.\nginx.exe如果已经启动过,重载配置:
cd C:\nginx
.\nginx.exe -s reload浏览器验证:
http://127.0.0.1/web/
http://127.0.0.1/app/11.3 注册 Nginx 为 Windows 服务
C:\nssm\win64\nssm.exe install YuQingNginxApplication:
| 字段 | 值 |
|---|---|
| Path | C:\nginx\nginx.exe |
| Startup directory | C:\nginx |
| Arguments | 空 |
Details:
| 字段 | 值 |
|---|---|
| Display name | YuQing Nginx |
| Startup type | Automatic |
点击 Install service 后启动:
Start-Service YuQingNginx
Get-Service YuQingNginx注意:如果用 NSSM 托管 Nginx,日常重载仍可执行:
cd C:\nginx
.\nginx.exe -s reload十二、前端和 H5 路径确认
12.1 PC 前端
当前 PC 前端生产配置:
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 生产配置:
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/ 代理即可。
十三、文件保存策略设置为本地
截图中的位置是:
基础设施 -> 文件管理 -> 文件配置客户现场单机部署时,文件保存策略必须设置为本地,避免仍使用示例的 S3、MinIO、七牛等配置。
13.1 准备本地文件目录
确认目录存在:
New-Item -ItemType Directory -Force C:\ruoyi-office\upload给运行后端服务的 Windows 用户授予读写权限。如果后端用本机管理员账号运行,一般无需额外处理;如果使用专用用户,请在目录属性里给该用户 读取、写入、修改 权限。
13.2 后台界面配置
登录 PC 管理端:
http://客户电脑IP/web/进入:
基础设施 -> 文件管理 -> 文件配置找到或新增本地存储配置,按以下值设置:
| 字段 | 建议值 |
|---|---|
| 配置名 | 本地存储(客户现场) |
| 存储器 | 本地存储 |
| 基础路径 / basePath | C:\ruoyi-office\upload |
| 自定义域名 / domain | http://客户电脑IP |
| 主配置 | 是 |
| 备注 | Windows 客户现场本地文件存储 |
如果已有截图中类似 本地存储(示例) 的配置,也可以直接编辑它:
- 点击
编辑。 - 把路径改为
C:\ruoyi-office\upload。 - 把域名改为客户实际访问地址,例如
http://192.168.1.10。 - 保存。
- 点击该行的
主配置,确保主配置列显示为是。
13.3 上传验证
在系统中找一个上传附件的位置,上传一张小图片或 PDF。
验证:
- 页面提示上传成功。
C:\ruoyi-office\upload下生成文件。- 点击预览或下载可以正常访问。
如果上传成功但无法预览,优先检查文件配置的 domain 是否和客户访问地址一致。
十四、安全策略和端口开放
14.1 端口规划
| 端口 | 服务 | 是否对外开放 | 说明 |
|---|---|---|---|
| 80 | Nginx HTTP | 是 | 客户访问入口 |
| 443 | Nginx HTTPS | 推荐 | 有证书时开放 |
| 48080 | 后端服务 | 否 | 只允许本机 Nginx 访问 |
| 3306 | MySQL | 否 | 只允许本机访问 |
| 6379 | Redis | 否 | 只允许本机访问 |
| 3389 | 远程桌面 | 谨慎 | 只允许管理员固定 IP |
14.2 Windows 防火墙配置
以管理员身份打开 PowerShell。
开放 HTTP:
New-NetFirewallRule -DisplayName "YuQing HTTP 80" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow如果配置 HTTPS,再开放 443:
New-NetFirewallRule -DisplayName "YuQing HTTPS 443" -Direction Inbound -Protocol TCP -LocalPort 443 -Action Allow明确阻止后端端口对外访问:
New-NetFirewallRule -DisplayName "Block YuQing Backend 48080" -Direction Inbound -Protocol TCP -LocalPort 48080 -Action Block明确阻止 MySQL 和 Redis 对外访问:
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查看规则:
Get-NetFirewallRule | Where-Object DisplayName -like "*YuQing*"14.3 账号和密码安全
上线前必须修改:
- MySQL
root密码。 - Redis 密码。
- 系统默认
admin密码。 - Druid 监控账号密码,如果开放使用。
- 所有示例配置中的第三方密钥、测试账号。
生产环境不建议:
- 对外暴露
/actuator全部端点。 - 对外暴露 Druid 控制台。
- 使用
admin/admin123。 - 使用公网 IP 直接开放
3306、6379、48080。
十五、完整启动顺序
每次服务器重启后,服务应自动启动。首次部署或手动排查时,按以下顺序启动:
- MySQL
- Redis 或 Memurai
- 后端
YuQingBackend - Nginx
YuQingNginx
PowerShell 命令:
Start-Service MySQL80
Start-Service Redis
Start-Service YuQingBackend
Start-Service YuQingNginx如果使用 Memurai,把 Redis 替换成实际服务名:
Get-Service *memurai*十六、上线验收清单
16.1 本机验收
在客户电脑浏览器访问:
http://127.0.0.1/web/
http://127.0.0.1/app/后端健康检查:
Invoke-WebRequest http://127.0.0.1:48080/actuator/health16.2 局域网验收
在另一台电脑或手机上访问:
http://客户电脑IP/web/
http://客户电脑IP/app/如果本机能访问,局域网不能访问,重点检查:
- Windows 防火墙是否开放
80。 - 客户电脑 IP 是否正确。
- 客户网络是否禁止设备互访。
- Nginx 是否正在运行。
16.3 功能验收
至少验证:
- PC 管理端可以打开登录页。
- 管理员账号可以登录。
- 菜单和列表可以正常加载。
- 移动端 H5 可以打开。
- 上传文件成功,并保存到
C:\ruoyi-office\upload。 - 刷新
/web/下任意页面不会 404。 - 刷新
/app/下任意页面不会 404。
十七、日常更新
17.1 更新后端
- 备份当前 JAR:
Copy-Item C:\ruoyi-office\app\backend\yudao-server.jar C:\ruoyi-office\backup\yudao-server-$(Get-Date -Format yyyyMMddHHmmss).jar- 停止后端:
Stop-Service YuQingBackend- 替换新的 JAR 到:
C:\ruoyi-office\app\backend\yudao-server.jar- 启动后端:
Start-Service YuQingBackend- 查看日志:
Get-Content C:\ruoyi-office\logs\yudao-server.log -Tail 100 -Wait17.2 更新 PC 前端
- 备份旧文件:
Compress-Archive C:\ruoyi-office\app\web\* C:\ruoyi-office\backup\web-$(Get-Date -Format yyyyMMddHHmmss).zip- 清空旧文件:
Remove-Item C:\ruoyi-office\app\web\* -Recurse -Force- 复制新的 PC 前端 dist 内容到:
C:\ruoyi-office\app\web- 重载 Nginx:
cd C:\nginx
.\nginx.exe -s reload17.3 更新移动端 H5
- 备份旧文件:
Compress-Archive C:\ruoyi-office\app\app\* C:\ruoyi-office\backup\h5-$(Get-Date -Format yyyyMMddHHmmss).zip- 清空旧文件:
Remove-Item C:\ruoyi-office\app\app\* -Recurse -Force- 复制新的 H5 构建产物内容到:
C:\ruoyi-office\app\app- 重载 Nginx:
cd C:\nginx
.\nginx.exe -s reload17.4 更新数据库
更新数据库前必须备份。
备份:
& "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执行增量:
& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -uroot -p ruoyi-office < C:\ruoyi-office\sql\增量文件.sql执行后重启后端:
Restart-Service YuQingBackend十八、备份策略
18.1 数据库备份
建议每天备份一次数据库,至少保留 7 到 30 天。
创建脚本:
C:\ruoyi-office\backup\backup-db.ps1内容:
$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 上传文件备份
备份上传目录:
Compress-Archive C:\ruoyi-office\upload\* C:\ruoyi-office\backup\upload-$(Get-Date -Format yyyyMMddHHmmss).zip建议把数据库备份和上传文件备份复制到另一块硬盘、NAS 或客户指定备份服务器,避免单机硬盘故障导致数据全部丢失。
十九、常见问题
Q1:访问 /web/ 或 /app/ 返回 404?
检查:
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 路径以 / 结尾:
alias C:/ruoyi-office/app/web/;
root C:/ruoyi-office/app;Q2:页面能打开,但接口 502?
说明 Nginx 没连上后端。
检查后端:
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被其他程序占用。
查看端口占用:
netstat -ano | findstr :48080Q3:后端启动失败,提示数据库连接失败?
检查:
- MySQL 服务是否运行:
Get-Service MySQL80 - 数据库是否存在:
ruoyi-office C:\ruoyi-office\conf\application-prod.yaml中数据库密码是否正确- MySQL 是否允许本机连接
手动测试:
& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -uroot -p -h127.0.0.1 -P3306 ruoyi-officeQ4:后端启动失败,提示 Redis 连接失败?
检查:
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:
http://客户电脑IP不要配置成:
http://127.0.0.1:48080客户浏览器访问时需要使用客户能访问到的地址。
Q7:局域网其他电脑访问不了?
检查:
ipconfig
Get-NetFirewallRule | Where-Object DisplayName -like "*YuQing*"确认:
- 客户访问的是正确 IP。
- Windows 防火墙已开放
80。 - Nginx 正在运行。
- 客户网络允许互访。
Q8:Nginx 修改配置后不生效?
执行:
cd C:\nginx
.\nginx.exe -t
.\nginx.exe -s reload如果提示端口被占用:
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 |
| 部署日期 | ________ |
| 部署人员 | ________ |
