Path: API › 网站管理

`POST /site`

创建新网站，支持 PHP 和纯静态两种类型。自动生成 Nginx/Apache 配置、创建网站目录、可选同时创建 FTP 和数据库。

## Request body

_Required._

- `action231.request_time` (string, required) — Unix 时间戳。
- `action231.request_token` (string, required) — 按 API 概览生成的签名。
- `action231.action` (string, required) — 具体操作名称。
  - one of `"AddSite"`
- `action231.webname` (string, required) — JSON 字符串，格式 `{"domain":"主域名","domainlist":[],"count":0}`
- `action231.path` (string, required) — 网站根目录路径，如 `/www/wwwroot/域名`
- `action231.type` (string, required) — 网站类型：`PHP` 或留空（纯静态）
- `action231.version` (string, required) — PHP 版本号，如 `85`；纯静态传 `00`
- `action231.port` (string, required) — 监听端口，默认 `80`
- `action231.type_id` (integer, optional) — 分类 ID，默认 `0`
- `action231.ps` (string, optional) — 备注
- `action231.ftp` (string, optional) — 是否同时创建 FTP：`"true"` / `"false"`
- `action231.sql` (string, optional) — 是否同时创建数据库：`"true"` / `"false"`
- `action231.codeing` (string, optional) — 数据库字符集，默认 `utf8`

## Example request

```text
{
  "request_time": "string",
  "request_token": "string",
  "action": "AddSite",
  "webname": "string",
  "path": "string",
  "type": "string",
  "version": "string",
  "port": "string",
  "type_id": 0,
  "ps": "string",
  "ftp": "string",
  "sql": "string",
  "codeing": "string"
}
```

## Code samples

### cURL（填写面板地址与签名）

```curl
curl --request POST \
  --url "https://your-panel.example.com:8888/site" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "request_time=<Unix时间戳>" \
  --data-urlencode "request_token=<按 API 概览生成的签名>" \
  --data-urlencode "action=AddSite" \
  --data-urlencode "webname=<webname>" \
  --data-urlencode "path=<path>" \
  --data-urlencode "type=<type>" \
  --data-urlencode "version=<version>" \
  --data-urlencode "port=<port>"
```

## Responses

### default

接口响应，业务状态见下方详细说明。

#### Example

```json
{
  "siteStatus": true,
  "siteId": 3,
  "ftpStatus": false,
  "databaseStatus": false,
  "gitStatus": false
}
```

- `action231.response.default.siteStatus` (boolean, optional) — 网站创建结果
- `action231.response.default.siteId` (integer, optional) — 新网站的 ID
- `action231.response.default.ftpStatus` (boolean, optional) — FTP 用户创建结果（`false` 表示未创建）
- `action231.response.default.databaseStatus` (boolean, optional) — 数据库创建结果（`false` 表示未创建）
- `action231.response.default.gitStatus` (boolean, optional) — Git 部署状态


## AddSite

创建新网站，支持 PHP 和纯静态两种类型。自动生成 Nginx/Apache 配置、创建网站目录、可选同时创建 FTP 和数据库。

- **路由**：`POST /site`
- **action**：`AddSite`

## 输入参数

| 参数名称 | 必选 | 类型 | 描述 |
|----------|------|------|------|
| action | 是 | String | 固定值 `AddSite` |
| webname | 是 | String | JSON 字符串，格式 `{"domain":"主域名","domainlist":[],"count":0}` |
| path | 是 | String | 网站根目录路径，如 `/www/wwwroot/域名` |
| type | 是 | String | 网站类型：`PHP` 或留空（纯静态） |
| version | 是 | String | PHP 版本号，如 `85`；纯静态传 `00` |
| port | 是 | String | 监听端口，默认 `80` |
| type_id | 否 | Integer | 分类 ID，默认 `0` |
| ps | 否 | String | 备注 |
| ftp | 否 | String | 是否同时创建 FTP：`"true"` / `"false"` |
| sql | 否 | String | 是否同时创建数据库：`"true"` / `"false"` |
| codeing | 否 | String | 数据库字符集，默认 `utf8` |

## 输出参数

| 参数名称 | 类型 | 描述 |
|----------|------|------|
| siteStatus | Boolean | 网站创建结果 |
| siteId | Integer | 新网站的 ID |
| ftpStatus | Boolean | FTP 用户创建结果（`false` 表示未创建） |
| databaseStatus | Boolean | 数据库创建结果（`false` 表示未创建） |
| gitStatus | Boolean | Git 部署状态 |

## 示例

### 创建 PHP 8.5 站点

```
POST /site HTTP/1.1
Content-Type: application/x-www-form-urlencoded

action=AddSite&webname={"domain":"demo.bt.local","domainlist":[],"count":0}&path=/www/wwwroot/demo.bt.local&type=PHP&version=85&port=80&ps=测试站点
```

```json
{"siteStatus": true, "siteId": 2, "ftpStatus": false, "databaseStatus": false, "gitStatus": false}
```

### 创建纯静态站点

```
action=AddSite&webname={"domain":"static.bt.local","domainlist":[],"count":0}&path=/www/wwwroot/static.bt.local&type=&version=00&port=80
```

> 纯静态不传 `type=PHP`，`version=00`。

```json
{"siteStatus": true, "siteId": 3, "ftpStatus": false, "databaseStatus": false, "gitStatus": false}
```

## 相关接口

- [DeleteSite](/api/site/deletesite) — 删除网站
- [GetPHPVersion](/api/site/getphpversion) — 获取可用 PHP 版本

