Files
AI-Chat/docs/DEPLOY.md

72 lines
1.5 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.
# 部署指南
## 宝塔面板部署
### 1. 环境准备
在宝塔面板"软件商店"中安装:
- Nginx 1.22+
- PHP 8.0(在 PHP 设置中确保以下扩展已启用pdo_mysql、curl、mbstring、json、openssl
- MySQL 5.7 或 8.0
### 2. 创建网站
1. 网站 → 添加站点
2. 填写域名
3. PHP 版本选择 **PHP 8.0**
4. 数据库选择"不创建"
### 3. 部署代码
```bash
cd /www/wwwroot/your-domain.com
git clone <repository-url> .
composer install
```
### 4. 设置权限
```bash
chmod -R 755 .
chown -R www:www .
```
### 5. 配置 Nginx
1. 站点设置 → 网站目录 → 运行目录改为 `/public`
2. 站点设置 → 配置文件 → 添加 `docs/baota-nginx-snippet.conf` 中的配置
### 6. 运行安装向导
访问 `http://your-domain.com/install.php`
### 7. SSL 配置(可选)
站点设置 → SSL → Let's Encrypt → 申请证书
## 手动部署
### Nginx 配置
参考 `docs/nginx.conf` 文件,将 `root` 指向 `public/` 目录。
### PHP-FPM 配置
确保 PHP-FPM 监听 socket 配置正确(通常为 `/tmp/php-cgi-80.sock``127.0.0.1:9000`)。
### 目录权限
```bash
chown -R www-data:www-data /path/to/ai-chat
chmod 755 /path/to/ai-chat/uploads
chmod 755 /path/to/ai-chat/config
```
## 安全建议
1. 配置 SSL 证书HTTPS
2. 修改数据库默认端口
3. 定期更新 PHP 和 Nginx 版本
4. 限制 uploads 目录的执行权限
5. 禁止访问 app/、config/、vendor/ 等非公开目录(已在 Nginx 配置中设置)