# APISIX CLI

APISIX CLI 是 Apache APISIX 内置的 `apisix` 运行时命令。你可以使用它初始化、启动、停止、重新加载和测试 APISIX 实例。

```
apisix [action] <argument>
```

## 命令[​](#命令 "命令的直接链接")

### `apisix help`[​](#apisix-help "apisix-help的直接链接")

打印 APISIX CLI 帮助菜单。

### `apisix init`[​](#apisix-init "apisix-init的直接链接")

初始化 `nginx.conf` 配置。

### `apisix init_etcd`[​](#apisix-init_etcd "apisix-init_etcd的直接链接")

初始化 etcd 中的数据。

### `apisix start`[​](#apisix-start "apisix-start的直接链接")

初始化并启动 APISIX 实例。

该命令在 OpenResty 以守护进程模式启动后返回，不会让容器或进程监控程序保持在前台运行。如果访问日志写入 `/dev/stdout`，命令返回后，工作进程仍会持有该输出流。

**选项：**

* `-h` 或 `--help`：打印帮助菜单。

* `-c` 或 `--config`：启动 APISIX 时指定自定义 [配置文件](https://docs.apiseven.com/apisix/reference/configuration-files.md) 的路径。例如：

  ```
  apisix start -c /path/to/custom_config.yaml
  ```

  如果未设置 `-c`，APISIX 将回退到默认配置。

* `--verbose`：显示 `init_etcd` 调试信息。

有关受支持的容器进程模型，请参阅[构建自定义 Docker 镜像](https://docs.apiseven.com/apisix/install/docker/build-custom-images.md#%E4%BF%9D%E7%95%99%E5%AE%B9%E5%99%A8%E5%85%A5%E5%8F%A3%E7%82%B9)。

### `apisix stop`[​](#apisix-stop "apisix-stop的直接链接")

立即停止正在运行的 APISIX 实例。APISIX 将停止所有工作进程，而不等待它们完成对任何未完成请求的服务。

### `apisix quit`[​](#apisix-quit "apisix-quit的直接链接")

优雅地退出正在运行的 APISIX 实例。APISIX 将等待所有工作进程完成对任何未完成请求的服务后再停止。

### `apisix restart`[​](#apisix-restart "apisix-restart的直接链接")

重启 APISIX 实例。此命令在停止和重启 APISIX 之前首先检查生成的 `nginx.conf` 配置。

### `apisix reload`[​](#apisix-reload "apisix-reload的直接链接")

重新加载 APISIX 实例。重新初始化 `nginx.conf` 并应用配置更改而不中断现有连接。

### `apisix test`[​](#apisix-test "apisix-test的直接链接")

测试生成的 `nginx.conf` 以验证配置。

### `apisix version`[​](#apisix-version "apisix-version的直接链接")

打印 APISIX 版本。

`apisix` 命令用于管理 APISIX 进程，而不是路由和上游等网关资源。有关资源管理方式，请参阅[管理方式](https://docs.apiseven.com/apisix/getting-started/management-options.md)。
