docs: 快速开始(含 DB 迁移步骤) + 生产部署指南
README.md: - 补充环境要求(Go 1.26 / PG 16 / Redis 7) - 添加数据库初始化迁移步骤 - 说明 .env 敏感信息注入 - 链接到部署文档 docs/deployment.md (新增): - 编译 + systemd 服务 - Nginx HTTPS 反向代理配置 - 生产环境 config.yaml 关键调整 - 首次注册站长 + 备份建议
This commit is contained in:
60
README.md
60
README.md
@ -70,21 +70,71 @@ MCE 是 **MetaZone Community Engine** 的缩写,是 MetaZone 品牌下的社
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 环境要求
|
||||
|
||||
| 依赖 | 最低版本 | 说明 |
|
||||
|------|----------|------|
|
||||
| Go | 1.26 | 编译运行 |
|
||||
| PostgreSQL | 16 | 主数据库 |
|
||||
| Redis | 7 | 会话存储(可选,关闭后使用内存存储) |
|
||||
|
||||
### 1. 克隆并配置
|
||||
|
||||
```bash
|
||||
# 克隆仓库
|
||||
git clone git@git.metazone.cc:MetaZone/mce.git
|
||||
cd mce
|
||||
```
|
||||
|
||||
# 配置数据库和 Redis
|
||||
cp .env.example .env
|
||||
# 编辑 .env 填入 PostgreSQL 和 Redis 连接信息
|
||||
编辑 `config.yaml`,修改数据库和 Redis 连接信息:
|
||||
|
||||
# 运行
|
||||
```yaml
|
||||
database:
|
||||
host: 127.0.0.1
|
||||
port: 5432
|
||||
user: metazone
|
||||
password: "your_password" # 或用 .env 注入
|
||||
dbname: metalab_dev # 提前创建此数据库
|
||||
|
||||
redis:
|
||||
enabled: true # false 则使用内存存储,无需 Redis
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password: ""
|
||||
```
|
||||
|
||||
敏感信息(数据库密码、Redis 密码)可通过 `.env` 注入:
|
||||
|
||||
```bash
|
||||
# .env(git 不追踪)
|
||||
DB_PASSWORD=your_password
|
||||
REDIS_PASSWORD=your_redis_password
|
||||
```
|
||||
|
||||
### 2. 初始化数据库
|
||||
|
||||
```bash
|
||||
# 按序执行迁移 SQL
|
||||
psql -U metazone -d metalab_dev -f docs/migrations/001_uid_to_id.sql
|
||||
psql -U metazone -d metalab_dev -f docs/migrations/002_announcements.sql
|
||||
psql -U metazone -d metalab_dev -f docs/migrations/003_post_attributes.sql
|
||||
psql -U metazone -d metalab_dev -f docs/migrations/004_categories_tags.sql
|
||||
psql -U metazone -d metalab_dev -f docs/migrations/005_scheduled_posts.sql
|
||||
```
|
||||
|
||||
首次部署后注册的第一个用户自动获得站长(owner)权限。
|
||||
|
||||
### 3. 启动
|
||||
|
||||
```bash
|
||||
go run cmd/server/main.go
|
||||
# 或编译后运行
|
||||
go build -o mce cmd/server/main.go && ./mce
|
||||
```
|
||||
|
||||
启动后访问 `http://localhost:8080`。
|
||||
|
||||
> 生产环境部署详见 [`docs/deployment.md`](docs/deployment.md)。
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user