Files
myblog/部署指南.md
T
2026-09-09 19:30:18 +08:00

69 lines
2.3 KiB
Markdown
Raw 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.
# 我的博客 · 环境部署指南
这是一份把本博客部署到另一台 Windows 电脑的说明。跟着步骤做即可。
## 1. 环境要求
- Windows 操作系统
- XAMPP(集成 Apache、PHP、MySQL,下载:https://www.apachefriends.org)
- 需要 PHP 的 pdo_mysql 扩展(XAMPP 默认已启用)
## 2. 安装步骤
### 2.1 安装 XAMPP
下载并安装 XAMPP,安装到任意目录,例如 `C:\xampp`。
### 2.2 放置项目
把整个 `myblog` 文件夹复制到 XAMPP 的 htdocs 目录下:
```
XAMPP安装目录\htdocs\myblog
```
例如:`C:\xampp\htdocs\myblog`
### 2.3 启动服务
1. 打开 XAMPP 控制面板(`xampp-control.exe`)
2. 点击 Apache 的 **Start**
3. 点击 MySQL 的 **Start**
### 2.4 导入数据库
1. 浏览器打开 `http://localhost/phpmyadmin`
2. 在左侧点 **新建**,创建一个名为 `myblog` 的数据库,排序规则选 `utf8mb4_general_ci`
3. 点进 `myblog` 数据库 → 顶部 **导入** → 选择本项目的 `sql/myblog.sql` 文件 → 执行
4. 导入成功后会生成 7 张表,并带有测试文章数据
### 2.5 配置数据库密码
项目的数据库配置在 `includes/config.php`,里面 MySQL 的 root 密码写的是 `root`:
- 如果你的 MySQL root 密码正好是 `root`:**无需改动**
- 如果 root 密码是空(XAMPP 默认):用 phpMyAdmin 把 root 密码设为 `root`,**或**打开 `includes/config.php` 把 `DB_PASS` 改成 `""`(空)
### 2.6 访问网站
- 前台:`http://localhost/myblog/`
- 后台管理:`http://localhost/myblog/admin/`
- 默认管理员账号:用户名 `admin`,密码 `123456`
## 3. 常见问题
| 问题 | 解决方法 |
|------|----------|
| Apache Start 后变红(端口被占用) | 关闭占用 80 端口的程序,或在 httpd.conf 改端口 |
| MySQL Start 后变红(端口被占用) | 关闭占用 3306 端口的程序 |
| 打开页面显示连接数据库失败 | 检查 config.php 的 DB_PASS 是否和 MySQL 实际密码一致 |
| 中文显示乱码 | 确认数据库 myblog 的排序规则是 utf8mb4 |
## 4. 目录说明
- `includes/` 公共函数、数据库连接、认证
- `admin/` 后台管理
- `assets/` CSS / JS
- `sql/` 数据库脚本(myblog.sql 是含数据的完整备份,init.sql 是空表结构)
- `uploads/` 上传目录