Files
plm-backend-service/INSTALL_REPORT.md
admin 0efeaff88e feat: PLM backend services - auth, user, project, config services
Sprint 0 backend development complete:
- auth-service: JWT authentication, login/logout, token refresh
- user-service: User CRUD, profile management, RBAC
- project-service: Project lifecycle, member management
- config-service: System configuration, audit logging

Technical stack:
- FastAPI async framework
- SQLAlchemy 2.0 async ORM
- JWT authentication with python-jose
- bcrypt password hashing
- Pydantic v2 validation

API endpoints: 31 total
Code lines: 3,551
2026-03-31 00:08:52 +08:00

6.2 KiB
Raw Permalink Blame History

PLM系统环境搭建报告

📋 任务概述

  • 任务: 在云服务器上搭建PLM系统运行环境
  • 域名: aifly.ren
  • 安装路径: ~/plm-system/ (Linux环境)
  • 完成时间: 2024-03-20

环境检查结果

系统信息

项目
主机名 ron-server
操作系统 Ubuntu 22.04.5 LTS
内核版本 6.8.0-106-generic
架构 x86_64
内存 30GB (可用28GB)

磁盘空间

分区 大小 已用 可用 状态
根分区 151GB 13% 125GB 充足
Docker分区 314GB 1% 298GB 充足

技术栈状态

已安装组件

组件 版本 状态
Python 3.10.12 已满足 (要求3.10+)
Node.js v22.22.1 已满足 (要求18+)
Docker 29.1.3 已安装

待安装组件

组件 版本 状态
PostgreSQL 14 📝 配置就绪 (Docker方式)
Nginx latest 📝 配置就绪

📁 目录结构

~/plm-system/
├── app/                          # 应用程序代码
│   ├── main.py                   # FastAPI主应用
│   ├── .env.example              # 环境变量模板
│   └── start.sh                  # 启动脚本
├── nginx/                        # Nginx配置
│   ├── nginx.conf                # 主配置文件
│   ├── conf.d/
│   │   └── aifly.ren.conf        # 域名配置
│   ├── html/
│   │   └── index.html            # 默认首页
│   └── ssl/                      # SSL证书目录
├── node/                         # Node.js前端
│   └── package.json              # 依赖配置
├── postgresql/                   # PostgreSQL数据
│   └── data/                     # 数据存储
├── python/                       # Python后端
│   ├── requirements.txt          # Python依赖
│   └── venv/                     # 虚拟环境(待创建)
├── redis/                        # Redis缓存
│   └── data/                     # 数据存储
├── docker-compose.yml            # Docker编排
├── install.sh                    # 安装脚本
├── test-env.sh                   # 测试脚本
└── INSTALL_REPORT.md             # 本报告

⚙️ 配置清单

1. Nginx配置

  • 主配置: ~/plm-system/nginx/nginx.conf
  • 域名配置: ~/plm-system/nginx/conf.d/aifly.ren.conf
  • 监听端口: 80, 443
  • 反向代理: 已配置到localhost:8000 (API) 和 localhost:3000 (前端)

2. PostgreSQL配置

  • 版本: 14
  • 数据库名: plm_database
  • 用户名: plm_admin
  • 密码: plm_secure_password_2024
  • 端口: 5432
  • 数据目录: ~/plm-system/postgresql/data

3. Python/FastAPI配置

  • 框架: FastAPI 0.104+
  • 服务器: Uvicorn
  • 端口: 8000
  • 依赖文件: ~/plm-system/python/requirements.txt

4. Node.js配置

  • 框架: Next.js 14
  • 端口: 3000
  • 依赖文件: ~/plm-system/node/package.json

5. Docker Compose配置

  • 服务: PostgreSQL 14, Redis 7, Nginx
  • 网络: plm-network
  • 编排文件: ~/plm-system/docker-compose.yml

🌐 域名配置

域名: aifly.ren

  • DNS A记录: 指向服务器IP 192.168.3.36
  • Nginx配置: 已配置支持 aifly.ren 和 www.aifly.ren
  • SSL: 配置模板已准备 (需申请证书)

🚀 部署步骤

方法1: 使用安装脚本 (推荐)

# 以root权限运行安装脚本
sudo ~/plm-system/install.sh

方法2: 使用Docker Compose

# 需要docker权限
cd ~/plm-system
docker-compose up -d

方法3: 手动安装

# 1. 安装系统依赖
sudo apt update
sudo apt install -y nginx postgresql-14 redis-server

# 2. 配置PostgreSQL
sudo systemctl start postgresql
sudo -u postgres psql -c "CREATE USER plm_admin WITH PASSWORD 'plm_secure_password_2024';"
sudo -u postgres psql -c "CREATE DATABASE plm_database OWNER plm_admin;"

# 3. 配置Nginx
sudo cp ~/plm-system/nginx/conf.d/aifly.ren.conf /etc/nginx/conf.d/
sudo nginx -t && sudo systemctl reload nginx

# 4. 安装Python依赖
python3 -m venv ~/plm-system/python/venv
source ~/plm-system/python/venv/bin/activate
pip install -r ~/plm-system/python/requirements.txt

# 5. 安装Node.js依赖
cd ~/plm-system/node
npm install

# 6. 启动应用
cd ~/plm-system/app
python3 main.py

🧪 测试验证

运行测试脚本

~/plm-system/test-env.sh

手动测试

# 测试Python应用
cd ~/plm-system/app
python3 main.py

# 访问健康检查
curl http://localhost:8000/health

# 测试Nginx
curl http://localhost/

预期输出

  • Health API: {"status": "healthy", "version": "1.0.0"}
  • Nginx: 返回PLM系统首页

📊 服务端口

服务 端口 用途
Nginx 80 HTTP入口
Nginx 443 HTTPS入口
FastAPI 8000 API服务
Next.js 3000 前端服务
PostgreSQL 5432 数据库
Redis 6379 缓存

🔐 安全配置

数据库

  • 强密码策略: plm_secure_password_2024
  • 专用用户: plm_admin
  • 仅本地访问 (可通过配置修改)

防火墙

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 8000/tcp

SSL证书 (待配置)

# 使用Let's Encrypt
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d aifly.ren -d www.aifly.ren

📝 注意事项

  1. 权限问题: 当前用户没有sudo权限完整安装需要root权限
  2. 网络问题: 安装Python依赖时可能遇到网络超时
  3. Docker权限: 当前用户不在docker组需要sudo运行docker命令
  4. 域名解析: 需要配置DNS将aifly.ren指向服务器IP

🔄 后续步骤

  1. 环境配置完成
  2. 申请SSL证书
  3. 配置DNS解析
  4. 部署应用代码
  5. 配置监控和日志

📞 技术支持

  • 安装脚本: ~/plm-system/install.sh
  • 测试脚本: ~/plm-system/test-env.sh
  • Docker编排: ~/plm-system/docker-compose.yml

报告生成时间: 2024-03-20 15:25:00
服务器: ron-server (Ubuntu 22.04.5 LTS)