This repository has been archived on 2026-03-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
kb-web/README.md
starmen1265 2300f9b7a0
Test CI / 快速测试 (push) Successful in 9s
更新 README.md
2026-03-01 23:36:14 +08:00

139 lines
2.7 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.
# 知识库网页系统
一个简单的知识库文档管理系统,支持多用户登录、文档列表和搜索。1
## 功能
- ✅ 账号密码登录
- ✅ 每个用户有独立的知识库目录
- ✅ 文档列表展示
- ✅ 关键词搜索(标题+内容)
- ✅ 在线查看文档(支持 Markdown)
- ✅ 管理员添加用户
## 目录结构
```
kb-web/
├── index.php # 登录页
├── dashboard.php # 文档列表 + 搜索
├── view.php # 查看文档内容
├── logout.php # 退出登录
├── config.php # 数据库配置
├── add_user.php # 添加用户脚本
├── style.css # 样式
├── init.sql # 数据库初始化
├── README.md # 说明文档
└── {username}/ # 用户文档目录
├── 文档1.md
└── 文档2.md
```
## 部署步骤
### 1. 上传文件
将整个 `kb-web` 目录上传到服务器的网站目录中。
### 2. 创建数据库
```bash
# 登录 MySQL
mysql -u root -p
# 执行初始化脚本
source init.sql
```
或者直接在 MySQL 中执行:
```sql
CREATE DATABASE IF NOT EXISTS kb_web DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
```
### 3. 修改配置
编辑 `config.php`,修改数据库连接信息:
```php
define('DB_HOST', 'localhost');
define('DB_NAME', 'kb_web');
define('DB_USER', 'your_db_user');
define('DB_PASS', 'your_db_password');
```
### 4. 添加用户
在服务器上执行:
```bash
cd /path/to/kb-web
php add_user.php 用户名 密码
```
示例:
```bash
php add_user.php zhangqing mypassword123
```
### 5. 添加文档
将用户的文档(.md 或 .txt 格式)放入对应用户目录:
```bash
cp ~/knowledge-base/analyzed/*.md /path/to/kb-web/zhangqing/
```
### 6. 访问
打开浏览器访问:`http://your-domain.com/kb-web/`
## 管理员操作
### 添加新用户
```bash
php add_user.php newuser newpassword
```
### 重置密码
```bash
# 删除旧用户
mysql -u root -p -e "DELETE FROM kb_web.users WHERE username='olduser';"
# 重新添加
php add_user.php olduser newpassword
```
### 批量导入文档
```bash
# 将分析好的文档复制到用户目录
cp ~/work/knowledge-base/analyzed/*.md /path/to/kb-web/zhangqing/
```
## 注意事项
1. **安全性**
- 修改 `config.php` 中的数据库密码
- 确保 `config.php` 不可被外部访问(LNMP 默认已处理)
- 定期备份数据库
2. **文件权限**
```bash
chown -R www-data:www-data /path/to/kb-web
chmod -R 755 /path/to/kb-web
```
3. **支持的文档格式**
- .md (Markdown)
- .txt (纯文本)
- .markdown
## 技术栈
- PHP 7.4+
- MySQL 5.7+
- 纯前端(HTML + CSS + JS)