补充安全的项目与部署说明

This commit is contained in:
amb
2026-09-09 18:42:03 +08:00
parent 08b79588ff
commit 041a348dde
2 changed files with 197 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
# 服务器部署说明
## 1. 获取代码
```bash
git clone https://git.aiameiba.com/amb/aiameiba_com_new.git
cd aiameiba_com_new
```
## 2. 配置后端
复制环境变量模板并填写服务器配置:
```bash
cp .env.example .env
```
`.env` 至少需要配置:
```dotenv
PORT=24731
DB_CLIENT=mysql
DB_HOST=47.109.98.44
DB_PORT=33306
DB_NAME=aiameiba_com_new
DB_USER=admin
DB_PASSWORD=请填写MySQL密码
ADMIN_INITIAL_PASSWORD=请设置管理员初始密码
NODE_ENV=production
```
初始化数据库并启动后端:
```bash
npm install
npm run migrate
npm start
```
后端地址:`http://服务器IP:24731`
## 3. 配置前端
```bash
cd frontend
```
创建 `frontend/.env.local`:
```dotenv
API_URL=http://127.0.0.1:24731
NEXT_PUBLIC_SITE_URL=http://服务器IP:28642
PORT=28642
```
构建并启动:
```bash
npm install
npm run build
npm start
```
前端地址:`http://服务器IP:28642`
## 4. 后台管理
后台地址为部署域名下的 `/admin`。管理员登录信息请通过安全渠道配置或获取,登录后应立即修改密码。`.env`、`.env.local`、数据库文件和构建缓存不会提交到仓库。
## 5. 推荐进程管理
可以使用 PM2 分别管理前后端:
```bash
pm2 start src/index.js --name aiameiba-api
pm2 start npm --name aiameiba-web -- start
pm2 save
```
执行第二条命令前请确认当前目录为 `frontend`。