forked from wangziqi/gongxue-base
docs: record baota server deployment notes
This commit is contained in:
@@ -44,6 +44,107 @@ sudo chown -R deploy:deploy /opt/tiku-saas /srv/tiku-saas
|
||||
sudo chmod 750 /etc/tiku-saas
|
||||
```
|
||||
|
||||
## 宝塔服务器实际落地记录
|
||||
|
||||
2026-07-01 首次上云使用的是 Alibaba Cloud Linux 3 + 宝塔面板环境。该服务器的 80/443 已由宝塔 Nginx 接管,主配置不在 `/etc/nginx`,而在:
|
||||
|
||||
```text
|
||||
/www/server/nginx/conf/nginx.conf
|
||||
/www/server/panel/vhost/nginx/*.conf
|
||||
```
|
||||
|
||||
因此在这类服务器上不要执行 `systemctl start nginx`、不要写 `/etc/nginx/sites-available`,也不要覆盖宝塔生成的站点配置。宝塔 Nginx 的测试和重载命令是:
|
||||
|
||||
```bash
|
||||
/www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf
|
||||
/www/server/nginx/sbin/nginx -s reload
|
||||
```
|
||||
|
||||
本次保留企业目录隔离方案:
|
||||
|
||||
```text
|
||||
/opt/tiku-saas/repo Gitea 工作副本
|
||||
/opt/tiku-saas/bin 服务器部署脚本
|
||||
/srv/tiku-saas/www H5 发布产物
|
||||
/srv/tiku-saas/data 运行数据
|
||||
/srv/tiku-saas/backups 备份
|
||||
/etc/tiku-saas 真实 env、Gitea token、运行时配置
|
||||
```
|
||||
|
||||
宝塔新增站点时会拦截 `/srv` 作为网站根目录。不要因此把密钥、仓库或运行数据搬进 `/www`。只为 H5 静态站点创建 `/www/wwwroot` 下的软链接:
|
||||
|
||||
```bash
|
||||
mkdir -p /www/wwwroot/tiku-saas
|
||||
ln -sfn /srv/tiku-saas/www/student /www/wwwroot/tiku-saas/student
|
||||
ln -sfn /srv/tiku-saas/www/tenant-admin /www/wwwroot/tiku-saas/tenant-admin
|
||||
ln -sfn /srv/tiku-saas/www/platform-admin /www/wwwroot/tiku-saas/platform-admin
|
||||
chown -h deploy:deploy /www/wwwroot/tiku-saas/student
|
||||
chown -h deploy:deploy /www/wwwroot/tiku-saas/tenant-admin
|
||||
chown -h deploy:deploy /www/wwwroot/tiku-saas/platform-admin
|
||||
```
|
||||
|
||||
宝塔面板中新增三个纯静态站点:
|
||||
|
||||
| 域名 | 宝塔根目录 |
|
||||
| --- | --- |
|
||||
| `app.tjszsb.com` | `/www/wwwroot/tiku-saas/student` |
|
||||
| `admin.tjszsb.com` | `/www/wwwroot/tiku-saas/tenant-admin` |
|
||||
| `console.tjszsb.com` | `/www/wwwroot/tiku-saas/platform-admin` |
|
||||
|
||||
每个站点需要保留 H5 history fallback,并禁止缓存公开运行时配置:
|
||||
|
||||
```nginx
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location = /runtime-config.json {
|
||||
add_header Cache-Control "no-store" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
```
|
||||
|
||||
当前服务器已经验证过的基础环境:
|
||||
|
||||
```text
|
||||
Node.js: v20.20.2,系统级安装在 /usr/bin/node,deploy 用户可用
|
||||
npm: 10.8.2,deploy 用户可用
|
||||
Docker: 26.1.3
|
||||
Docker Compose: v2.27.0
|
||||
Nginx: 宝塔 /www/server/nginx/sbin/nginx,1.30.1
|
||||
```
|
||||
|
||||
不要使用 root 的 nvm Node 路径作为生产运行时。若 `deploy` 用户看不到 Node/NPM,应安装系统级 NodeSource Node.js 20:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://rpm.nodesource.com/setup_20.x | bash -
|
||||
dnf install -y nodejs
|
||||
sudo -u deploy bash -lc 'command -v node; command -v npm; node -v; npm -v'
|
||||
```
|
||||
|
||||
大陆服务器 `npm ci` 可能访问 npm 官方源超时。本次部署在 `/etc/tiku-saas/deploy.env` 中使用可配置 npm registry 和重试参数:
|
||||
|
||||
```bash
|
||||
NPM_REGISTRY=https://registry.npmmirror.com
|
||||
NPM_FETCH_RETRIES=5
|
||||
NPM_FETCH_RETRY_MINTIMEOUT=20000
|
||||
NPM_FETCH_RETRY_MAXTIMEOUT=120000
|
||||
NPM_FETCH_TIMEOUT=300000
|
||||
```
|
||||
|
||||
截至 2026-07-01 21:39,`sudo -u deploy /opt/tiku-saas/bin/deploy.sh` 已完成:
|
||||
|
||||
- Gitea `main` 拉取到 `/opt/tiku-saas/repo`。
|
||||
- `npm ci` 安装依赖。
|
||||
- `npm run security:repo`,结果 0 finding。
|
||||
- `node scripts/production-launch-gate-test.js`,通过。
|
||||
- API 和 worker 构建通过。
|
||||
- 学生端、租户后台、平台后台三套 Taro H5 构建通过。
|
||||
- H5 发布到 `/srv/tiku-saas/www/student`、`/srv/tiku-saas/www/tenant-admin`、`/srv/tiku-saas/www/platform-admin`。
|
||||
- 三个 `runtime-config.json` 已安装到各自 H5 根目录。
|
||||
|
||||
Taro H5 构建存在 webpack asset size warning,这是前端包体优化事项,不影响当前部署继续进行。后续可做拆包、按需加载和 KaTeX 字体裁剪。
|
||||
|
||||
## 首次安装
|
||||
|
||||
1. 安装基础组件:Docker、Docker Compose、Node.js 20+、Nginx、Certbot、Git、rsync、flock。
|
||||
|
||||
Reference in New Issue
Block a user