← Back to Skills Marketplace
aapanel

btpanel phpsite 宝塔面板PHP网站

by aapanel.com · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ⚠ suspicious
135
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install btpanel-phpsite
Description
宝塔面板 PHP 网站管理技能,提供站点创建、删除、启停、PHP 版本切换、域名管理、SSL 证书管理、伪静态管理、数据库管理等功能
README (SKILL.md)

\r \r

宝塔面板 PHP 网站管理\r

\r 宝塔面板 PHP 网站管理技能,提供完整的 PHP 网站生命周期管理功能,包括站点创建、删除、启停、PHP 版本切换、域名管理、SSL 证书管理、伪静态规则配置、数据库管理等。\r \r 宝塔面板\r \r

图标资源\r

\r 技能包提供以下图标文件,可在生成报告时引用:\r \r | 文件 | 格式 | 用途 |\r |------|------|------|\r | icon/bt-logo.svg | SVG | 矢量图标,适合缩放 |\r \r

AI 使用约束\r

\r 本技能用于管理和修改服务器上的 PHP 网站,AI 应遵循以下原则:\r \r

  1. 操作前确认:删除、停用网站等操作前必须向用户确认\r
  2. 执行前告知:网站管理会影响线上服务,AI 应先向用户简述即将执行的操作步骤\r
  3. 数据安全:删除网站时提醒用户备份数据和数据库\r
  4. 隐私保护:不主动泄露敏感信息(如数据库密码、SSL 私钥等)\r
  5. 影响评估:修改 PHP 版本、SSL 证书等操作前,告知用户可能的影响\r \r 执行流程示例:\r
AI: 我将为您执行以下操作:\r
    1. 创建新站点 example.com\r
    2. 设置 PHP 版本为 8.2\r
    3. 创建关联数据库\r
    正在获取数据,请稍候...\r
    [执行命令]\r
    [展示结果和站点信息]\r
```\r
\r
## 宝塔面板相关技能矩阵\r
\r
当前宝塔面板技能包,共包含 3 个相互关联的技能:\r
\r
| 技能名称                | 描述 | 依赖关系                              |\r
|---------------------|------|-----------------------------------|\r
| **btpanel**         | 运维监控技能 | ✅ 基础技能,主要用于资源监控、网站状态检查、服务状态检查等    |\r
| **btpanel-files**   | 文件管理技能 | ✅ 提供远程服务器文件辅助服务,可以读取文件列表和内容       |\r
| **btpanel-phpsite** | PHP 网站管理技能 | ✅ 提供远程服务器 PHP 网站管理功能,能够部署和管理php网站 |\r
\r
### ⚠️ 常见问题\r
\r
```\r
\r
**问题 1: 配置文件不存在**\r
```\r
错误:未找到配置文件\r
解决:运行 python3 bt-config.py add 添加服务器配置\r
```\r
\r
**问题 2: WordPress 部署失败**\r
```\r
错误:无法下载或解压文件\r
解决:确保 btpanel-files 技能已安装,提供文件操作能力\r
```\r
\r
**问题 3: PYTHONPATH 未设置**\r
```bash\r
# 运行脚本前需要设置\r
export PYTHONPATH=/path/to/btpanel-skills/src:$PYTHONPATH\r
```\r
\r
### 检查命令\r
\r
```bash\r
# 检查 bt_common 模块\r
python3 -c "from bt_common.bt_client import BtClient; print('✅ 模块正常')"\r
\r
# 检查配置文件\r
ls -la ~/.openclaw/bt-skills.yaml\r
\r
# 测试站点管理\r
python3 {baseDir}/scripts/site.py list --server "你的服务器名"\r
\r
# 测试文件管理(WordPress 部署需要)\r
python3 {baseDir}/../btpanel_files/scripts/download.py --help\r
```\r
\r
### 完整安装验证\r
\r
```bash\r
# 1. 检查所有技能目录\r
ls -la /path/to/btpanel-skills/src/\r
# 应包含:btpanel/ btpanel_files/ btpanel_phpsite/ bt_common/\r
\r
# 2. 检查配置文件\r
cat ~/.openclaw/bt-skills.yaml\r
\r
# 3. 测试完整流程(WordPress 部署)\r
python3 {baseDir}/scripts/site.py add -n "test.com:8080" --create-db --server "你的服务器名"\r
python3 {baseDir}/../btpanel_files/scripts/download.py --url "https://example.com/file.zip" --path "/tmp" --server "你的服务器名"\r
```\r
\r
---\r
\r
## 服务器配置管理\r
\r
> **重要:** 没有服务器信息时需要先添加\r
\r
本技能复用 `btpanel` 技能的配置系统,使用 `bt-config.py` 工具管理服务器:\r
\r
```bash\r
# 查看帮助\r
python3 {baseDir}/scripts/bt-config.py -h\r
\r
# 添加服务器\r
python3 {baseDir}/scripts/bt-config.py add -n prod-01 -H https://panel.example.com:8888 -t YOUR_TOKEN\r
\r
# 列出服务器\r
python3 {baseDir}/scripts/bt-config.py list\r
\r
# 删除服务器\r
python3 {baseDir}/scripts/bt-config.py remove prod-01\r
```\r
\r
**获取 API Token 的方法**:\r
1. 登录宝塔面板\r
2. 进入「面板设置」->「API 接口」\r
3. 点击「获取 API Token」\r
\r
**重要提示 - SSL 证书验证配置**:\r
添加服务器时,AI 应询问用户:\r
> "您的宝塔面板是否使用了受信任的 SSL 证书(如 Let's Encrypt、商业 CA 证书)?"\r
\r
- ✅ **是**(受信任证书)→ 使用默认配置,无需额外参数\r
- ⚠️ **否**(自签名证书)→ 添加 `--verify-ssl false` 参数\r
\r
**示例**:\r
```bash\r
# 自签名证书场景\r
python3 {baseDir}/scripts/bt-config.py add -n prod-01 -H https://panel.example.com:8888 -t YOUR_TOKEN --verify-ssl false\r
\r
# 受信任证书场景(默认)\r
python3 {baseDir}/scripts/bt-config.py add -n prod-01 -H https://panel.example.com:8888 -t YOUR_TOKEN\r
```\r
\r
## 常用场景\r
\r
### 场景一:创建新 PHP 网站\r
\r
当用户需要创建新的 PHP 网站时:\r
\r
```bash\r
# 创建基础 PHP 站点\r
python3 {baseDir}/scripts/site.py add -n example.com -p /www/wwwroot/example.com -v 82\r
\r
# 创建站点并关联数据库\r
python3 {baseDir}/scripts/site.py add -n example.com -v 82 --create-db --db-user example_user --db-password "SecurePass123"\r
\r
# 创建站点并同时创建 FTP\r
python3 {baseDir}/scripts/site.py add -n example.com -v 82 --create-ftp --ftp-user ftpuser --ftp-password "FtpPass123"\r
```\r
\r
**用户意图识别**:\r
- "帮我创建一个新网站" → 执行 `site.py add`\r
- "新建一个 PHP 站点" → 执行 `site.py add`\r
- "创建网站并配数据库" → 执行 `site.py add --create-db`\r
\r
### 场景二:查看网站列表和状态\r
\r
当用户需要查看网站列表或状态时:\r
\r
```bash\r
# 查看所有站点\r
python3 {baseDir}/scripts/site.py list\r
\r
# 查看站点详情\r
python3 {baseDir}/scripts/site.py info -n example.com\r
\r
# 查看已安装的 PHP 版本\r
python3 {baseDir}/scripts/php.py versions\r
\r
# 查看站点的 PHP 版本\r
python3 {baseDir}/scripts/php.py get -n example.com\r
```\r
\r
**用户意图识别**:\r
- "看看有哪些网站" → 执行 `site.py list`\r
- "查看网站状态" → 执行 `site.py list` 或 `site.py info`\r
- "支持哪些 PHP 版本" → 执行 `php.py versions`\r
\r
### 场景三:切换 PHP 版本\r
\r
当用户需要修改站点的 PHP 版本时:\r
\r
```bash\r
# 切换站点 PHP 版本\r
python3 {baseDir}/scripts/php.py set -n example.com -v 82\r
\r
# 切换为纯静态站点\r
python3 {baseDir}/scripts/php.py set -n example.com --static\r
```\r
\r
**用户意图识别**:\r
- "把这个站点的 PHP 版本升级到 8.2" → 执行 `php.py set -v 82`\r
- "切换到 PHP 7.4" → 执行 `php.py set -v 74`\r
- "改为静态站点" → 执行 `php.py set --static`\r
\r
### 场景四:停用/启用网站\r
\r
当用户需要临时停用或启用网站时:\r
\r
```bash\r
# 停用网站\r
python3 {baseDir}/scripts/site.py stop -n example.com\r
\r
# 启用网站\r
python3 {baseDir}/scripts/site.py start -n example.com\r
```\r
\r
**用户意图识别**:\r
- "暂时关闭这个网站" → 执行 `site.py stop`\r
- "启用停用的站点" → 执行 `site.py start`\r
- "把这个站先停了" → 执行 `site.py stop`\r
\r
### 场景五:删除网站\r
\r
当用户需要删除网站时:\r
\r
```bash\r
# 删除网站(保留文件和数据库)\r
python3 {baseDir}/scripts/site.py delete -n example.com\r
\r
# 删除网站并删除文件目录\r
python3 {baseDir}/scripts/site.py delete -n example.com --delete-path\r
\r
# 删除网站并删除关联数据库\r
python3 {baseDir}/scripts/site.py delete -n example.com --delete-db\r
\r
# 完全删除(网站 + 文件 + 数据库+FTP)\r
python3 {baseDir}/scripts/site.py delete -n example.com --delete-path --delete-db --delete-ftp\r
```\r
\r
**用户意图识别**:\r
- "删除这个网站" → 确认后执行 `site.py delete`\r
- "彻底删除网站和所有数据" → 确认后执行 `site.py delete --delete-path --delete-db`\r
\r
**重要**:删除操作不可逆,必须先向用户确认并提醒备份。\r
\r
### 场景六:管理域名绑定\r
\r
当用户需要添加或删除绑定域名时:\r
\r
```bash\r
# 查看站点域名列表\r
python3 {baseDir}/scripts/domain.py list -n example.com\r
\r
# 添加域名\r
python3 {baseDir}/scripts/domain.py add -n example.com -d www.example.com\r
\r
# 添加多个域名\r
python3 {baseDir}/scripts/domain.py add -n example.com -d test.example.com,www2.example.com\r
\r
# 删除域名\r
python3 {baseDir}/scripts/domain.py delete -n example.com -d www.example.com\r
```\r
\r
**用户意图识别**:\r
- "给这个站加个域名" → 执行 `domain.py add`\r
- "绑定新域名" → 执行 `domain.py add`\r
- "删除绑定的域名" → 执行 `domain.py delete`\r
\r
### 场景七:管理 SSL 证书\r
\r
当用户需要配置 SSL 证书时:\r
\r
```bash\r
# 查看 SSL 证书信息\r
python3 {baseDir}/scripts/ssl_cert.py info -n example.com\r
\r
# 上传 SSL 证书\r
python3 {baseDir}/scripts/ssl_cert.py upload -n example.com --key /path/to/key.pem --cert /path/to/cert.pem\r
\r
# 申请免费证书\r
python3 {baseDir}/scripts/ssl_cert.py apply -n example.com -d example.com,www.example.com\r
\r
# 开启强制 HTTPS\r
python3 {baseDir}/scripts/ssl_cert.py https -n example.com --enable\r
\r
# 关闭强制 HTTPS\r
python3 {baseDir}/scripts/ssl_cert.py https -n example.com --disable\r
\r
# 关闭 SSL\r
python3 {baseDir}/scripts/ssl_cert.py close -n example.com\r
```\r
\r
**用户意图识别**:\r
- "查看证书状态" → 执行 `ssl_cert.py info`\r
- "上传 SSL 证书" → 执行 `ssl_cert.py upload`\r
- "申请免费证书" → 执行 `ssl_cert.py apply`\r
- "开启强制 HTTPS" → 执行 `ssl_cert.py https --enable`\r
\r
---\r
\r
### ⚠️ 申请免费 SSL 证书重要提示\r
\r
**Let's Encrypt 免费证书申请条件:**\r
\r
#### 1. 域名验证方式(二选一)\r
\r
**方式 A: HTTP 文件验证(推荐)**\r
- ✅ 域名必须能正常解析到服务器 IP\r
- ✅ **80 端口必须开放**(未被防火墙阻止)\r
- ✅ 网站必须能正常通过 HTTP 访问\r
- ✅ 验证文件需要能被 Let's Encrypt 服务器访问\r
- ✅ 适合单个域名或不含通配符的多个域名\r
\r
**方式 B: DNS 验证**\r
- ✅ 需要域名服务商支持 API 修改 DNS 记录\r
- ✅ 需要提供域名服务商的 API Key/Secret\r
- ✅ 适合通配符证书 (*.example.com)\r
- ✅ 不需要 80 端口开放\r
- ✅ **宝塔购买域名**:如果在宝塔面板购买了域名服务,使用其内置 DNS 能力,相当于已配置域名服务商 API\r
- ⚠️ **配置方法**:在宝塔面板 -> 网站 -> SSL -> DNS 验证 中配置 DNS 服务商 API 凭证\r
\r
#### 2. 域名要求\r
- ❌ **不支持 IP 地址申请证书**(Let's Encrypt 仅支持域名)\r
- ❌ 不支持内网 IP(Let's Encrypt 无法访问验证)\r
- ✅ 域名必须已备案(中国大陆服务器)\r
- ✅ 一个证书最多包含 100 个域名\r
\r
#### 3. 证书限制\r
- ⚠️ Let's Encrypt 证书有效期 **90 天**\r
- ⚠️ 每 3 个月需要续期一次(宝塔支持自动续期)\r
- ⚠️ 每周申请次数限制(约 50 次/周/域名)\r
\r
#### 4. 常见错误场景\r
\r
**错误 1: 使用 IP 地址申请**\r
```\r
❌ 错误:申请 IP 地址 192.168.69.172 的证书\r
✅ 正确:必须使用域名,如 example.com\r
```\r
\r
**错误 2: 域名未解析到服务器**\r
```\r
❌ 错误:域名解析到其他服务器\r
✅ 正确:域名必须解析到当前服务器 IP\r
```\r
\r
**错误 3: 80 端口被阻止**\r
```\r
❌ 错误:防火墙阻止 80 端口\r
✅ 正确:开放 80 端口用于 HTTP 验证\r
```\r
\r
**错误 4: 内网域名申请**\r
```\r
❌ 错误:申请 inner.local 等内网域名\r
✅ 正确:使用公网可访问的域名\r
```\r
\r
**错误 5: DNS 验证未配置**\r
```\r
❌ 错误:使用 DNS 验证但未配置 DNS 服务商 API\r
✅ 正确:先在面板中配置 DNS 服务商 API 凭证\r
```\r
\r
#### 5. 申请前检查清单\r
\r
```bash\r
# 1. 检查域名解析\r
ping example.com\r
# 应该解析到服务器 IP\r
\r
# 2. 检查 80 端口\r
curl -I http://example.com\r
# 应该能正常访问\r
\r
# 3. 绑定域名到站点\r
python3 {baseDir}/scripts/domain.py add -n example.com -d example.com\r
\r
# 4. 验证网站访问\r
curl http://example.com\r
# 应该返回正常内容\r
```\r
\r
#### 6. 推荐申请流程\r
\r
```bash\r
# 步骤 1: 绑定域名\r
python3 {baseDir}/scripts/domain.py add -n example.com -d example.com,www.example.com\r
\r
# 步骤 2: 申请证书(HTTP 验证)\r
python3 {baseDir}/scripts/ssl_cert.py apply -n example.com -d example.com,www.example.com\r
\r
# 步骤 3: 开启强制 HTTPS\r
python3 {baseDir}/scripts/ssl_cert.py https -n example.com --enable\r
\r
# 步骤 4: 验证证书\r
python3 {baseDir}/scripts/ssl_cert.py info -n example.com\r
```\r
\r
**提示用户话术:**\r
> "申请免费 SSL 证书需要满足以下条件:\r
> 1. 使用域名(不能用 IP 地址)\r
> 2. 域名已解析到当前服务器\r
> 3. 80 端口开放(HTTP 验证方式)\r
> 4. 如果是通配符证书或在宝塔购买了域名,可以使用 DNS 验证方式\r
> 5. DNS 验证需要先在面板配置 DNS 服务商 API 凭证\r
> \r
> 请问您的域名是否已解析到当前服务器?"\r
\r
---\r
\r
### 📄 证书申请日志\r
\r
**日志路径:** `/www/server/panel/logs/letsencrypt.log`\r
\r
**查看日志方法:**\r
```bash\r
# 手动查看\r
tail -50 /www/server/panel/logs/letsencrypt.log\r
\r
# 或使用脚本(申请失败时自动查看)\r
python3 {baseDir}/scripts/ssl_cert.py apply -n example.com -d example.com\r
```\r
\r
**申请失败时:**\r
- 脚本会自动读取日志最后 50 行\r
- 过滤出错误相关的日志\r
- 显示最近 10 条错误信息\r
- 提供解决方案建议\r
\r
**常见日志错误:**\r
- `Connection refused` - 80 端口未开放或域名未解析\r
- `Invalid domain` - 域名格式错误\r
- `DNS verification failed` - DNS 验证失败(检查 API 配置)\r
- `Rate limit exceeded` - 达到申请频率限制(等待一段时间)\r
\r
### 场景八:管理伪静态规则\r
\r
当用户需要配置伪静态规则时:\r
\r
```bash\r
# 查看伪静态模板列表\r
python3 {baseDir}/scripts/rewrite.py list -n example.com\r
\r
# 查看当前伪静态规则\r
python3 {baseDir}/scripts/rewrite.py get -n example.com\r
\r
# 应用 WordPress 伪静态规则\r
python3 {baseDir}/scripts/rewrite.py set -n example.com -t wordpress\r
\r
# 应用 ThinkPHP 规则\r
python3 {baseDir}/scripts/rewrite.py set -n example.com -t thinkphp\r
\r
# 自定义伪静态规则\r
python3 {baseDir}/scripts/rewrite.py set -n example.com --custom "location / { try_files $uri $uri/ /index.php?$query_string; }"\r
```\r
\r
**用户意图识别**:\r
- "设置伪静态规则" → 执行 `rewrite.py set`\r
- "用 WordPress 的伪静态" → 执行 `rewrite.py set -t wordpress`\r
- "查看当前的伪静态" → 执行 `rewrite.py get`\r
\r
### 场景九:管理数据库\r
\r
当用户需要管理 MySQL 数据库时:\r
\r
```bash\r
# 查看数据库列表\r
python3 {baseDir}/scripts/database.py list\r
\r
# 查看数据库详情\r
python3 {baseDir}/scripts/database.py info -d example_db\r
\r
# 创建数据库\r
python3 {baseDir}/scripts/database.py add -n example_db -u example_user -P "SecurePass123"\r
\r
# 修改数据库密码\r
python3 {baseDir}/scripts/database.py password -d example_db -P "NewPass123"\r
\r
# 设置数据库访问权限\r
python3 {baseDir}/scripts/database.py access -d example_db -a %\r
\r
# 查看数据库表信息\r
python3 {baseDir}/scripts/database.py tables -d example_db\r
\r
# 优化数据库表\r
python3 {baseDir}/scripts/database.py optimize -d example_db\r
\r
# 修复数据库表\r
python3 {baseDir}/scripts/database.py repair -d example_db\r
\r
# 删除数据库\r
python3 {baseDir}/scripts/database.py delete -d example_db\r
```\r
\r
**用户意图识别**:\r
- "创建数据库" → 执行 `database.py add`\r
- "查看有哪些数据库" → 执行 `database.py list`\r
- "修改数据库密码" → 执行 `database.py password`\r
- "优化数据库" → 执行 `database.py optimize`\r
\r
## 版本要求\r
\r
- **宝塔面板**: >= 9.0.0\r
- **Python**: >= 3.10\r
\r
## 用法\r
\r
### 站点管理\r
\r
```bash\r
# 查看站点列表\r
python3 {baseDir}/scripts/site.py list\r
\r
# 创建站点\r
python3 {baseDir}/scripts/site.py add -n example.com -p /www/wwwroot/example.com -v 82\r
\r
# 停用站点\r
python3 {baseDir}/scripts/site.py stop -n example.com\r
\r
# 启用站点\r
python3 {baseDir}/scripts/site.py start -n example.com\r
\r
# 删除站点\r
python3 {baseDir}/scripts/site.py delete -n example.com\r
```\r
\r
### PHP 版本管理\r
\r
```bash\r
# 查看 PHP 版本列表\r
python3 {baseDir}/scripts/php.py versions\r
\r
# 查看站点 PHP 版本\r
python3 {baseDir}/scripts/php.py get -n example.com\r
\r
# 设置 PHP 版本\r
python3 {baseDir}/scripts/php.py set -n example.com -v 82\r
```\r
\r
### 域名管理\r
\r
```bash\r
# 查看域名列表\r
python3 {baseDir}/scripts/domain.py list -n example.com\r
\r
# 添加域名\r
python3 {baseDir}/scripts/domain.py add -n example.com -d www.example.com\r
\r
# 删除域名\r
python3 {baseDir}/scripts/domain.py delete -n example.com -d www.example.com\r
```\r
\r
### SSL 证书管理\r
\r
```bash\r
# 查看 SSL 信息\r
python3 {baseDir}/scripts/ssl_cert.py info -n example.com\r
\r
# 上传证书\r
python3 {baseDir}/scripts/ssl_cert.py upload -n example.com --key key.pem --cert cert.pem\r
\r
# 申请免费证书\r
python3 {baseDir}/scripts/ssl_cert.py apply -n example.com -d example.com\r
\r
# 开启/关闭强制 HTTPS\r
python3 {baseDir}/scripts/ssl_cert.py https -n example.com --enable\r
python3 {baseDir}/scripts/ssl_cert.py https -n example.com --disable\r
\r
# 关闭 SSL\r
python3 {baseDir}/scripts/ssl_cert.py close -n example.com\r
```\r
\r
### 伪静态管理\r
\r
```bash\r
# 查看模板列表\r
python3 {baseDir}/scripts/rewrite.py list -n example.com\r
\r
# 查看当前规则\r
python3 {baseDir}/scripts/rewrite.py get -n example.com\r
\r
# 应用模板\r
python3 {baseDir}/scripts/rewrite.py set -n example.com -t wordpress\r
```\r
\r
### 数据库管理\r
\r
```bash\r
# 查看数据库列表\r
python3 {baseDir}/scripts/database.py list\r
\r
# 创建数据库\r
python3 {baseDir}/scripts/database.py add -n testdb -u testuser -P "Password123"\r
\r
# 修改密码\r
python3 {baseDir}/scripts/database.py password -d testdb -P "NewPass123"\r
\r
# 删除数据库\r
python3 {baseDir}/scripts/database.py delete -d testdb\r
```\r
\r
## 参数说明\r
\r
### site.py 参数\r
\r
| 参数 | 说明 | 默认值 |\r
|------|------|--------|\r
| `list` | 查看站点列表 | - |\r
| `add` | 创建站点 | - |\r
| `stop` | 停用站点 | - |\r
| `start` | 启用站点 | - |\r
| `delete` | 删除站点 | - |\r
| `info` | 查看站点详情 | - |\r
| `-n, --name` | 站点名称 | 必填 |\r
| `-p, --path` | 站点路径 | `/www/wwwroot/域名` |\r
| `-v, --version` | PHP 版本 | `82` |\r
| `--create-db` | 创建数据库 | 否 |\r
| `--create-ftp` | 创建 FTP | 否 |\r
| `--delete-path` | 删除站点目录 | 否 |\r
| `--delete-db` | 删除关联数据库 | 否 |\r
| `--delete-ftp` | 删除关联 FTP | 否 |\r
\r
### php.py 参数\r
\r
| 参数 | 说明 | 默认值 |\r
|------|------|--------|\r
| `versions` | 查看 PHP 版本列表 | - |\r
| `get` | 查看站点 PHP 版本 | - |\r
| `set` | 设置 PHP 版本 | - |\r
| `-n, --name` | 站点名称 | 必填 |\r
| `-v, --version` | PHP 版本号 | 必填 |\r
| `--static` | 设为纯静态 | - |\r
\r
### domain.py 参数\r
\r
| 参数 | 说明 | 默认值 |\r
|------|------|--------|\r
| `list` | 查看域名列表 | - |\r
| `add` | 添加域名 | - |\r
| `delete` | 删除域名 | - |\r
| `-n, --name` | 站点名称 | 必填 |\r
| `-d, --domain` | 域名(多个用逗号分隔) | 必填 |\r
\r
### ssl_cert.py 参数\r
\r
| 参数 | 说明 | 默认值 |\r
|------|------|--------|\r
| `info` | 查看 SSL 信息 | - |\r
| `upload` | 上传证书 | - |\r
| `apply` | 申请证书 | - |\r
| `https` | 设置强制 HTTPS | - |\r
| `close` | 关闭 SSL | - |\r
| `-n, --name` | 站点名称 | 必填 |\r
| `-d, --domain` | 域名列表 | - |\r
| `--key` | 私钥文件路径 | - |\r
| `--cert` | 证书文件路径 | - |\r
\r
### rewrite.py 参数\r
\r
| 参数 | 说明 | 默认值 |\r
|------|------|--------|\r
| `list` | 查看模板列表 | - |\r
| `get` | 查看当前规则 | - |\r
| `set` | 设置规则 | - |\r
| `-n, --name` | 站点名称 | 必填 |\r
| `-t, --template` | 模板名称 | - |\r
| `--custom` | 自定义规则 | - |\r
\r
### database.py 参数\r
\r
| 参数 | 说明 | 默认值 |\r
|------|------|--------|\r
| `list` | 查看数据库列表 | - |\r
| `add` | 创建数据库 | - |\r
| `info` | 查看数据库详情 | - |\r
| `password` | 修改密码 | - |\r
| `access` | 设置访问权限 | - |\r
| `tables` | 查看表信息 | - |\r
| `optimize` | 优化表 | - |\r
| `repair` | 修复表 | - |\r
| `delete` | 删除数据库 | - |\r
| `-n, --name` | 数据库名称 | 必填 |\r
| `-u, --user` | 数据库用户名 | 同数据库名 |\r
| `-P, --password` | 密码 | 随机生成 |\r
| `-d, --database` | 数据库名称 | 必填 |\r
| `-a, --access` | 访问权限 | `127.0.0.1` |\r
\r
## 支持的 PHP 版本\r
\r
| 版本 | 说明 |\r
|------|------|\r
| `52` | PHP 5.2 (已淘汰) |\r
| `53` | PHP 5.3 (已淘汰) |\r
| `54` | PHP 5.4 (已淘汰) |\r
| `55` | PHP 5.5 (已淘汰) |\r
| `56` | PHP 5.6 |\r
| `70` | PHP 7.0 |\r
| `71` | PHP 7.1 |\r
| `72` | PHP 7.2 |\r
| `73` | PHP 7.3 |\r
| `74` | PHP 7.4 |\r
| `80` | PHP 8.0 |\r
| `81` | PHP 8.1 |\r
| `82` | PHP 8.2 |\r
| `83` | PHP 8.3 |\r
| `84` | PHP 8.4 |\r
| `00` | 纯静态 |\r
\r
## 支持的伪静态模板\r
\r
常见伪静态模板:\r
- `wordpress` - WordPress\r
- `thinkphp` - ThinkPHP\r
- `laravel5` - Laravel 5\r
- `dedecms` - Dedecms\r
- `discuz` - Discuz\r
- `ecshop` - ECShop\r
- `typecho` - Typecho\r
- `zblog` - Z-Blog\r
- `drupal` - Drupal\r
- `phpcms` - PHPCMS\r
- `maccms` - 苹果 CMS\r
- `crmeb` - CRMEB\r
- `ShopWind` - 商派\r
- `EmpireCMS` - 帝国 CMS\r
- `EduSoho` - EduSoho\r
\r
### 场景十:完整部署 WordPress 网站(实战示例)\r
\r
> **实战更新日期:** 2026-04-02  \r
> **测试环境:** 内网 172 (192.168.69.172:8888)  \r
> **WordPress 版本:** 6.9.4 (最新中文版)\r
\r
当用户需要从头部署一个完整的 WordPress 网站时,按以下步骤执行:\r
\r
#### 步骤 1:环境检查\r
\r
```bash\r
python3 {baseDir}/scripts/php.py versions\r
python3 {baseDir}/scripts/site.py list\r
```\r
\r
#### 步骤 2:创建站点并配置数据库\r
\r
```bash\r
python3 {baseDir}/scripts/site.py add -s "内网 172" \\r
    -n "192.168.69.172:19101" \\r
    -v 74 \\r
    --create-db \\r
    --db-user "wp_db_101"\r
```\r
\r
**输出示例:**\r
```\r
✅ 站点创建成功:192.168.69.172:19101\r
   路径:/www/wwwroot/192.168.69.172_19101\r
   PHP 版本:74\r
   站点 ID: 24\r
   ✅ 数据库创建成功\r
      数据库名:wp_db_101\r
      用户名:wp_db_101\r
      密码:9q87Fbr8On41lzoT\r
```\r
\r
#### 步骤 3:下载 WordPress 源码\r
\r
```bash\r
python3 ../btpanel_files/scripts/download.py -s "内网 172" \\r
    download \\r
    --url "https://cn.wordpress.org/latest-zh_CN.zip" \\r
    --path "/www/wwwroot/192.168.69.172_19101" \\r
    --wait \\r
    --timeout 300\r
```\r
\r
#### 步骤 4:解压到临时目录\r
\r
```bash\r
python3 ../btpanel_files/scripts/unzip.py -s "内网 172" \\r
    unzip \\r
    --source "/www/wwwroot/192.168.69.172_19101/latest-zh_CN.zip" \\r
    --dest "/tmp/wp-extract"\r
```\r
\r
#### 步骤 5:复制文件到站点根目录\r
\r
```bash\r
PYTHONPATH=/mnt/c/Work/lpanel2/btpanel-skills/src python3 -c "\r
from bt_common.bt_client import BtClient\r
from bt_common.config import get_servers\r
servers = get_servers()\r
for s in servers:\r
    if s.name == '内网 172':\r
        client = BtClient(name=s.name, host=s.host, token=s.token, timeout=s.timeout)\r
        break\r
client.request('/files?action=CopyFile', {'sfile': '/tmp/wp-extract/wordpress', 'dfile': '/www/wwwroot/192.168.69.172_19101'})\r
"\r
```\r
\r
#### 步骤 6:配置 wp-config.php\r
\r
```bash\r
# 创建文件\r
python3 ../btpanel_files/scripts/files.py -s "内网 172" \\r
    touch "/www/wwwroot/192.168.69.172_19101/wp-config.php"\r
\r
# 准备配置内容\r
python3 ../btpanel_files/scripts/files.py -s "内网 172" \\r
    cat "/www/wwwroot/192.168.69.172_19101/wp-config-sample.php" > /tmp/wp-config.txt\r
\r
# 替换数据库配置\r
sed -i 's/database_name_here/wp_db_101/g; s/username_here/wp_db_101/g; s/password_here/9q87Fbr8On41lzoT/g; s/localhost/127.0.0.1/g' /tmp/wp-config.txt\r
\r
# 写入配置\r
python3 ../btpanel_files/scripts/files.py -s "内网 172" \\r
    edit "/www/wwwroot/192.168.69.172_19101/wp-config.php" \\r
    -f /tmp/wp-config.txt\r
```\r
\r
#### 步骤 7:应用伪静态规则\r
\r
```bash\r
python3 {baseDir}/scripts/rewrite.py -s "内网 172" \\r
    set -n "192.168.69.172_19101" -t wordpress\r
```\r
\r
#### 步骤 8:验证访问\r
\r
```bash\r
curl -I http://192.168.69.172:19101\r
```\r
\r
**预期输出:**\r
```\r
HTTP/1.1 302 Found\r
X-Redirect-By: WordPress\r
Location: http://192.168.69.172:19101/wp-admin/install.php\r
```\r
\r
---\r
\r
### 部署完成信息\r
\r
```markdown\r
## 🎉 WordPress 部署完成!\r
\r
| 项目 | 值 |\r
|------|------|\r
| 访问地址 | http://192.168.69.172:19101 |\r
| 数据库名 | wp_db_101 |\r
| 用户名 | wp_db_101 |\r
| 密码 | 9q87Fbr8On41lzoT |\r
| 数据库主机 | 127.0.0.1 |\r
```\r
\r
### 关键注意事项\r
\r
1. **数据库参数自动传递** - 脚本已自动处理 `sql=true` 参数\r
2. **下载大文件使用 --wait** - 确保下载完成\r
3. **解压到临时目录** - 避免子目录问题\r
4. **wp-config.php 配置** - 必须正确配置数据库连接\r
5. **伪静态规则必需** - WordPress 正常工作必要条件\r
6. **端口选择** - 建议使用 19000+ 避免冲突\r
\r
\r
## 注意事项\r
\r
1. **删除操作谨慎**:删除站点、数据库等操作不可逆,操作前务必备份数据\r
2. **PHP 版本兼容**:切换 PHP 版本前,确认网站代码兼容新版本\r
3. **SSL 证书申请**:申请免费证书需要域名能正常解析且 80 端口开放\r
4. **数据库权限**:设置数据库访问权限时,`%` 表示允许远程连接,`127.0.0.1` 表示仅本地访问\r
5. **伪静态规则**:应用伪静态规则前,建议先查看当前规则并备份\r
6. **API 参数要求**:创建站点时宝塔 API 要求明确传递 `sql` 和 `ftp` 参数(脚本已自动处理)\r
Usage Guidance
This skill largely does what it says — it's a collection of Python CLI tools that operate against a BT-Panel instance using an API token. Before installing: 1) Inspect bt_common/bt_client.py and related files to confirm there are no hardcoded remote endpoints or unexpected network calls; 2) Be aware you must supply a panel API token (the scripts will use and may persist it in ~/.openclaw/bt-skills.yaml); 3) Understand the scripts can read config files and may print sensitive data (database passwords, etc.) — avoid using tokens with broader privileges than necessary and do not share output indiscriminately; 4) The registry claims 'instruction-only' but the package contains executable code — treat this as a packaging mismatch and review the source fully before running; 5) Run in an isolated environment (dedicated VM or container) or review and test scripts locally with non-production credentials first. If you need higher assurance, request the author to provide an explicit install spec, minimal dependency list, and a short security note explaining where secrets are stored and what outputs include.
Capability Analysis
Type: OpenClaw Skill Name: btpanel-phpsite Version: 1.0.1 The skill bundle is a legitimate administrative tool for managing PHP websites on BT-Panel (宝塔面板). It provides a well-structured Python library (`bt_common`) and several CLI scripts (`site.py`, `database.py`, `ssl_cert.py`, etc.) that wrap the BT-Panel API. The bundle correctly implements the panel's MD5-based request signing and manages server credentials (API tokens) in a local configuration file (`~/.openclaw/bt-skills.yaml`). While the tool has high-privilege capabilities such as deleting databases and managing SSL keys, its logic is transparent and strictly follows the stated purpose. The `SKILL.md` file includes proactive safety instructions for the AI agent, such as requiring user confirmation for destructive actions and protecting sensitive data.
Capability Assessment
Purpose & Capability
Name/description (BT-Panel PHP site management) align with the included Python CLI scripts (site.py, php.py, domain.py, database.py, ssl_cert.py, rewrite.py) and the single required binary (python3). However the registry/metadata described the package as 'instruction-only' / 'no install spec' while the bundle contains many executable code files and a bt_common client — this mismatch is meaningful and should be treated as a packaging/integrity discrepancy.
Instruction Scope
SKILL.md and the scripts instruct the agent to run many local Python scripts against configured panel servers. The scripts read local configuration (~/.openclaw/bt-skills.yaml or BT_CONFIG_PATH), interact with remote panel APIs (using a user-supplied API token), and several CLI commands print sensitive data (e.g., database info and passwords are displayed in database.cmd_info). While these actions are coherent with site management, they increase the risk of exposing secrets and broaden data-access scope beyond simple 'status checks'.
Install Mechanism
No install spec is provided (no automated download/install), which lowers some supply-chain risk, but the package includes many Python scripts and a local bt_common library that will be executed by the agent. Dependencies (requests, pyyaml, etc.) are required per README/check_env but not installed automatically. There are no external download URLs in the supplied files, which is good, but the lack of an explicit install step means the code will run directly from the skill bundle — review source before execution.
Credentials
The skill declares no required environment variables and only requires python3. In practice the scripts read configuration files (GLOBAL_CONFIG_FILE under the user's home, optional BT_CONFIG_PATH) and rely on a user-supplied BT Panel API token (expected for this purpose). They do not request unrelated cloud credentials, which is appropriate. Caveat: the scripts may output sensitive fields from the panel (DB passwords, possibly other secrets returned by the panel API).
Persistence & Privilege
The skill is not marked 'always: true' and does not request elevated platform privileges in metadata. It uses its own config file paths (global config under the user's home) and does not appear to modify other skills' configurations. Autonomous invocation is allowed (platform default) but not combined with high privileges here.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install btpanel-phpsite
  3. After installation, invoke the skill by name or use /btpanel-phpsite
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
btpanel-phpsite 1.0.1 - 补充了宝塔相关技能依赖矩阵信息,让依赖更清晰简明 - 明确了 SSL 证书验证方式配置提示,添加对自签名与受信任证书的区分说明 - 精简、整理了依赖关系描述,减少重复;常见问题与检查方法调整为表格和代码块 - 其它内容保持不变,功能无实质改动
v1.0.0
Initial release of the btpanel-phpsite skill. - Provides PHP website management for 宝塔面板, including site creation, deletion, enable/disable, PHP version switching, domain and SSL certificate management, rewrite rules, and database management. - Integrates with the btpanel skill’s configuration system; some features depend on btpanel-files. - Includes clear user confirmation and data safety prompts for sensitive operations. - Offers sample commands and common use-case guides for creating, configuring, and managing websites. - Details installation prerequisites and troubleshooting tips for seamless setup.
Metadata
Slug btpanel-phpsite
Version 1.0.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is btpanel phpsite 宝塔面板PHP网站?

宝塔面板 PHP 网站管理技能,提供站点创建、删除、启停、PHP 版本切换、域名管理、SSL 证书管理、伪静态管理、数据库管理等功能. It is an AI Agent Skill for Claude Code / OpenClaw, with 135 downloads so far.

How do I install btpanel phpsite 宝塔面板PHP网站?

Run "/install btpanel-phpsite" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is btpanel phpsite 宝塔面板PHP网站 free?

Yes, btpanel phpsite 宝塔面板PHP网站 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does btpanel phpsite 宝塔面板PHP网站 support?

btpanel phpsite 宝塔面板PHP网站 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created btpanel phpsite 宝塔面板PHP网站?

It is built and maintained by aapanel.com (@aapanel); the current version is v1.0.1.

💬 Comments