Files
shop-platform/docs/deploy.md

81 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 部署说明
## 部署准备
1. 备份服务器上最新代码
``` bash
# 备份服务器上最新代码
cd /www/tools/
php backup_restore.php backup --source=/www/wwwroot/myweb/newfwq/ --backup-dir=./backup --config=./backup_config.php --verbose --dry-run
```
2. 查看依赖环境
- PHP版本7.4.3nts
- 数据库MySQL、Redis
- 服务器Nginx + PHP-FPM
- 环境变量: .env文件
3. 下载备份文件到本地
作为二次备份及版本管理,下载备份文件到本地,以便后续需要时可以恢复。
## 还原备份
``` bash
php backup_restore.php restore --file=backup.tar.gz --target=/path/to/target
# 示例,还原备份文件到指定目录
cd /www/tools/
php backup_restore.php restore --file=./backup/newfwq_backup_2025-11-12_134620.tar.gz --target=/www/tools/test-newfwq/
```
## 自动部署
### 准备条件
- 1. 下载备份文件到本地
- 2. 查看依赖环境
- 3. 解压到本地的ftp-src目录确保目录结构正确相关目录以备份文件为主。也就是说先清空ftp-src下的相关子目录再解压备份文件到该目录
- 4. 利用比较工具如Beyond Compare比较备份文件与当前代码的差异确保没有重要的代码变更。
- 5. 确认备份文件与当前代码的差异,无重要变更后,再进行创建部署包
### 创建部署包
```bash
# 代码示例
cd /d/projects/shop-projects/backend
php ./scripts/generate_deploy_package.php --source ./src --target ./ftp-src --output update.zip
# Linux
php ./scripts/generate_deploy_package.php --source ./src --target ./ftp-src --output update.zip
```
## 部署流程
### 测试环境
``` bash
# 部署流程
cd /var/www/all_source
# 测试本地部署
php ./scripts/deploy.php --zip update.zip --target ./ftp-src --dry-run --verbose
# 实际部署
php ./scripts/deploy.php --zip update.zip --target ./ftp-src --verbose
```
### 真实环境部署
``` base
cd /www/tools
php ./deploy.php --zip update.zip --target /www/wwwroot/myweb/newfwq --dry-run --verbose
```