158 lines
3.0 KiB
Markdown
158 lines
3.0 KiB
Markdown
# 安心验后端 API 线上部署说明
|
|
|
|
## 1. 当前部署目标
|
|
|
|
- API 域名:`api.anxinjianyan.com`
|
|
- 项目目录建议:`/www/wwwroot/anxinyan-api`
|
|
- 服务监听端口:`8787`
|
|
|
|
当前后端基于 `webman`,推荐部署方式:
|
|
|
|
1. 代码上传到服务器
|
|
2. 使用 `php start.php start -d` 启动常驻进程
|
|
3. 使用 `Nginx` 反向代理到 `127.0.0.1:8787`
|
|
4. 用 `systemd` 管理进程自启动
|
|
|
|
## 2. 本次已准备好的发布包
|
|
|
|
发布包路径:
|
|
|
|
- [/Users/wushumin/www/biyou/anxinyan/releases/anxinyan-server-api-20260422.zip](/Users/wushumin/www/biyou/anxinyan/releases/anxinyan-server-api-20260422.zip)
|
|
|
|
建议上传后解压到:
|
|
|
|
```bash
|
|
mkdir -p /www/wwwroot/anxinyan-api
|
|
unzip anxinyan-server-api-20260422.zip -d /www/wwwroot/anxinyan-api
|
|
```
|
|
|
|
## 3. 服务器要求
|
|
|
|
- PHP 8.1+
|
|
- 扩展:
|
|
- `pdo`
|
|
- `pdo_mysql`
|
|
- `pcntl`
|
|
- 建议 `opcache`
|
|
- MySQL 8+
|
|
- Redis 6/7
|
|
- `Nginx`
|
|
- `systemd`
|
|
|
|
## 4. 部署步骤
|
|
|
|
### 4.1 上传并解压
|
|
|
|
```bash
|
|
cd /www/wwwroot
|
|
mkdir -p anxinyan-api
|
|
tar -xzf /path/to/anxinyan-server-api-20260422.tar.gz -C anxinyan-api
|
|
cd anxinyan-api
|
|
```
|
|
|
|
### 4.2 检查目录权限
|
|
|
|
```bash
|
|
mkdir -p runtime/logs storage/payment-certs
|
|
chmod -R 775 runtime storage
|
|
```
|
|
|
|
### 4.3 确认环境变量
|
|
|
|
发布包中已包含当前 `.env`,但上线前仍需人工确认:
|
|
|
|
- `APP_ENV=production`
|
|
- `APP_DEBUG=false`
|
|
- 数据库连接是否为正式库
|
|
- Redis 连接是否为正式实例
|
|
|
|
## 5. 启动命令
|
|
|
|
### 首次启动
|
|
|
|
```bash
|
|
cd /www/wwwroot/anxinyan-api
|
|
php start.php start -d
|
|
```
|
|
|
|
### 重载
|
|
|
|
```bash
|
|
cd /www/wwwroot/anxinyan-api
|
|
php start.php reload -d
|
|
```
|
|
|
|
### 停止
|
|
|
|
```bash
|
|
cd /www/wwwroot/anxinyan-api
|
|
php start.php stop
|
|
```
|
|
|
|
## 6. Nginx 配置
|
|
|
|
示例文件:
|
|
|
|
- [api.anxinjianyan.com.nginx.conf.example](/Users/wushumin/www/biyou/anxinyan/docs/deploy/api.anxinjianyan.com.nginx.conf.example)
|
|
|
|
核心逻辑:
|
|
|
|
- 对外监听 `80/443`
|
|
- 反向代理到 `127.0.0.1:8787`
|
|
- 保留真实 IP、协议头和 Host
|
|
|
|
## 7. systemd 配置
|
|
|
|
示例文件:
|
|
|
|
- [anxinyan-api.service.example](/Users/wushumin/www/biyou/anxinyan/docs/deploy/anxinyan-api.service.example)
|
|
|
|
放置路径建议:
|
|
|
|
```bash
|
|
/etc/systemd/system/anxinyan-api.service
|
|
```
|
|
|
|
启用命令:
|
|
|
|
```bash
|
|
systemctl daemon-reload
|
|
systemctl enable anxinyan-api
|
|
systemctl start anxinyan-api
|
|
systemctl status anxinyan-api
|
|
```
|
|
|
|
## 8. 上线后立即检查
|
|
|
|
### 接口联通
|
|
|
|
```bash
|
|
curl http://127.0.0.1:8787/
|
|
curl https://api.anxinjianyan.com/
|
|
```
|
|
|
|
### 冒烟验证
|
|
|
|
```bash
|
|
cd /www/wwwroot/anxinyan-api
|
|
php tools/smoke_check.php
|
|
php tools/release_audit.php
|
|
```
|
|
|
|
## 9. 当前仍需人工确认的阻塞项
|
|
|
|
- 小程序正式配置:
|
|
- `mini_program.app_id`
|
|
- `mini_program.app_secret`
|
|
- `mini_program.original_id`
|
|
|
|
## 10. 特别说明
|
|
|
|
- 当前数据库中的支付证书路径仍是本机绝对路径,若线上要用微信支付,建议在服务器后台重新上传:
|
|
- `apiclient_key.pem`
|
|
- `apiclient_cert.pem`
|
|
- 后台系统配置中的支付回调地址已调整为:
|
|
- `https://api.anxinjianyan.com`
|
|
- H5 页面根地址已调整为:
|
|
- `https://m.anxinjianyan.com`
|