Guanghu Domestic Migration a27e87cb99 chore: import sanitized domestic snapshot for REPO-007
Source snapshot: 97d7f0fae96dc04b7ddad56fc1db6a108ed662cc

[SEC-CLEAN] · pre-push-clean v1.0 · 109处敏感信息已自动转乱码
2026-07-17 15:59:55 +08:00

138 lines
4.0 KiB
Markdown
Raw Permalink 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.

# 2026-05-23 · 肥猫码字平台 · Phase 1 地基搭建记录
## 📋 任务概要
**日期**2026-05-23周六晚
**执行人**:肥猫 + 霜砚
**目标**:在现有新加坡服务器上,搭建肥猫网文码字平台的 Next.js 地基骨架
**结果**:✅ Phase 1 地基搭通,外网可访问
---
## 🖥️ 服务器状态确认Phase 0
| 项目 | 结果 |
| --- | --- |
| PM2 进程 | shushu-chat (online, 68MB, 13天) + shushu-memory (online, 49MB, 14天) |
| Nginx | 配置语法OK |
| 磁盘 | 50G 用了 8.3G,剩余 39G18% |
| 内存 | 总 2G可用 1414MB |
| Node.js | v20.20.2 ✅Next.js 需要 ≥18 |
| 舒舒页面 | 正常访问 ✅ |
---
## 🔨 Phase 1 执行步骤
### Step 1 · 安装 PostgreSQL
```bash
sudo apt update
sudo apt install -y postgresql postgresql-contrib
```
- 状态:`active (exited)` — 正常 ✅
- 端口5432
### Step 2 · 创建 Next.js 项目
```bash
cd ~
npx create-next-app@latest feimao-platform --typescript --tailwind --eslint --app --src-dir --no-import-alias
```
- 路径:`/home/ubuntu/feimao-platform`
- 注意:`/opt/guanghu/modules/` 目录权限归 root无法直接写入改用 home 目录
- create-next-app 版本16.2.6
- 依赖360 packages
### Step 3 · PM2 启动服务
```bash
cd ~/feimao-platform
npm run build
pm2 start "npx next start -p 3002" --name feimao-platform
```
- 端口30023001被残留进程占用切到3002
- `curl http://localhost:3002` 返回完整 HTML ✅
### Step 4 · Nginx 反向代理配置
**问题**:腾讯云安全组未开 3002 端口,外网无法直连
**方案**:复用 80 端口Nginx 按 server_name 分流
**修改后的配置**
`/etc/nginx/sites-enabled/shushu`去掉IP
```
server {
listen 80;
server_name guanghushushu.site www.guanghushushu.site;
location / {
proxy_pass http://127.0.0.1:3333;
...
}
}
```
`/etc/nginx/sites-available/feimao-platform`加上IP
```
server {
listen 80;
server_name guanghu.site www.guanghu.site 43.133.36.90;
location / {
proxy_pass http://127.0.0.1:3002;
...
}
}
```
软链接:`/etc/nginx/sites-enabled/feimao-platform → /etc/nginx/sites-available/feimao-platform`
---
## ✅ 当前架构
| 组件 | 地址 | 端口 | 状态 |
| --- | --- | --- | --- |
| 舒舒对话 | [guanghushushu.site](http://guanghushushu.site) | 3333 | ✅ 正常 |
| 肥猫码字平台 | 43.133.36.90[guanghu.site](http://guanghu.site) 域名待生效) | 3002 | ✅ 已跑通 |
| PostgreSQL | [localhost](http://localhost) | 5432 | ✅ 已装 |
| Nginx | 80 端口双站点代理 | 80 | ✅ 配置完成 |
| PM2 进程 | shushu-chat / shushu-memory / feimao-platform | — | ✅ 全部 online |
---
## 🔜 下一步Phase 1 剩余)
- [ ] 改首页(`~/feimao-platform/src/app/page.tsx`)→ 深色科幻风落地页
- [ ] 加路由骨架:`/login`(登录)、`/chat`(对话)、`/dashboard`(工作台)
- [ ] 配 Tailwind 深色主题
- [ ] 迁移舒舒对话功能到 `/chat` 路由
## 🔜 后续阶段
- [ ] Phase 2 · 用户系统 + 人格体绑定PostgreSQL 用户表 + 邀请码 + 注册登录)
- [ ] Phase 3 · 对话系统升级WebSocket 多轮对话 + 消息历史 + 人格体动态 prompt
- [ ] [guanghu.site](http://guanghu.site) 域名 DNS 生效确认
---
## ⚠️ 踩坑记录
1. **目录权限**`/opt/guanghu/modules/` 归 rootubuntu 用户无法创建子目录 → 改用 `/home/ubuntu/`
2. **端口占用**3001 被之前 PM2 反复重启的残留进程占用EADDRINUSE→ 改用 3002
3. **PM2 启动方式**`pm2 start npm --name x -- start` 方式在 Next.js 下不稳定 → 改用 `pm2 start "npx next start -p 3002"`
4. **Nginx IP 分流**:原 shushu 配置的 server_name 包含 IP `43.133.36.90`,新站点配置未含 IP → IP访问全走舒舒 → 从 shushu 移出 IP加到 feimao-platform
5. **Nginx 软链接**:误敲 `-v` 后缀导致文件名错误 → 删除重建
---
*记录人:霜砚 · 2026-05-23 23:21*