v1.2修复优化

This commit is contained in:
2026-05-08 10:05:31 +08:00
parent 80b71a973a
commit 4cf6bd4b4b
12 changed files with 238 additions and 128 deletions

View File

@@ -14,7 +14,7 @@
1. 网站 → 添加站点
2. 填写域名
3. PHP 版本选择 **PHP 8.0**
4. 数据库选择"不创建"
4. 数据库选择"不创建"(安装向导会连接你手动创建的数据库)
### 3. 部署代码
@@ -31,30 +31,65 @@ chmod -R 755 .
chown -R www:www .
```
### 5. 配置 Nginx
### 5. 配置伪静态
1. 站点设置 → 网站目录 → 运行目录改为 `/public`
2. 站点设置 → 配置文件添加 `docs/baota-nginx-snippet.conf` 中的配置
2. 站点设置 → **伪静态** `docs/baota-nginx-snippet.conf` 的内容粘贴进去,保存
### 6. 运行安装向导
> 注意:是粘贴到"伪静态"输入框,不是"配置文件"。
> 如 PHP 版本不是 8.0,需将 `php-cgi-80` 改为对应版本号(如 `php-cgi-81`)。
访问 `http://your-domain.com/install.php`
### 6. 创建数据库
### 7. SSL 配置(可选)
安装向导不会自动创建数据库,需要你提前手动创建:
1. 宝塔面板 → 数据库 → 添加数据库
2. 记录数据库名、用户名和密码,安装向导中需要填写
### 7. 运行安装向导
访问 `http://your-domain.com/install.php`,按步骤完成安装。
### 8. SSL 配置(可选)
站点设置 → SSL → Let's Encrypt → 申请证书
## 手动部署
---
### Nginx 配置
## 手动部署Nginx + PHP-FPM
参考 `docs/nginx.conf` 文件,将 `root` 指向 `public/` 目录。
### 1. 安装依赖
### PHP-FPM 配置
```bash
composer install
```
确保 PHP-FPM 监听 socket 配置正确(通常为 `/tmp/php-cgi-80.sock``127.0.0.1:9000`)。
### 2. Nginx 站点配置
### 目录权限
使用 `docs/nginx.conf` 作为完整的站点配置文件:
```bash
# 复制到 Nginx 配置目录
cp docs/nginx.conf /etc/nginx/sites-available/ai-chat
ln -s /etc/nginx/sites-available/ai-chat /etc/nginx/sites-enabled/
# 编辑配置,修改 server_name 和 root 路径
vim /etc/nginx/sites-available/ai-chat
# 测试并重载
nginx -t && nginx -s reload
```
### 3. 创建数据库
```sql
CREATE DATABASE ai_chat DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'ai_chat'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON ai_chat.* TO 'ai_chat'@'localhost';
FLUSH PRIVILEGES;
```
### 4. 目录权限
```bash
chown -R www-data:www-data /path/to/ai-chat
@@ -62,6 +97,22 @@ chmod 755 /path/to/ai-chat/public/uploads
chmod 755 /path/to/ai-chat/config
```
### 5. 运行安装向导
访问 `http://your-domain.com/install.php`
---
## 本地开发PHP 内置服务器)
```bash
php -S localhost:8080 -t public/ public/router.php
```
> 必须使用 `public/router.php` 作为路由文件,否则 `/api/*` 请求无法正确路由到 `api.php`。
---
## 安全建议
1. 配置 SSL 证书HTTPS