> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unla.amoylab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 二进制部署

> 使用二进制文件部署 MCP Gateway

## 支持平台

目前支持以下平台的二进制部署：

<CardGroup cols={2}>
  <Card title="Linux AMD64" icon="linux">
    适用于 x86\_64 架构的 Linux 系统
  </Card>

  <Card title="Linux ARM64" icon="linux">
    适用于 ARM64 架构的 Linux 系统
  </Card>
</CardGroup>

您可以在 [GitHub Releases](https://github.com/amoylab/unla/releases) 查看和下载最新的二进制文件。

## 部署步骤

<Steps>
  <Step title="创建目录并下载配置">
    ```bash theme={null}
    mkdir -p unla/{configs,data}
    cd unla/
    curl -sL https://raw.githubusercontent.com/amoylab/unla/refs/heads/main/configs/apiserver.yaml -o configs/apiserver.yaml
    curl -sL https://raw.githubusercontent.com/amoylab/unla/refs/heads/main/configs/mcp-gateway.yaml -o configs/mcp-gateway.yaml
    curl -sL https://raw.githubusercontent.com/amoylab/unla/refs/heads/main/.env.example -o .env
    ```
  </Step>

  <Step title="调整 PID 文件路径（macOS 用户）">
    <Note>
      在 macOS 下，`/var/run/mcp-gateway.pid` 可能没有写入权限，需要调整路径。
    </Note>

    ```bash theme={null}
    sed -i 's|/var/run/mcp-gateway.pid|./data/mcp-gateway.pid|g' .env
    ```
  </Step>

  <Step title="下载二进制文件">
    根据您的系统架构选择合适的二进制文件：

    **Linux AMD64:**

    ```bash theme={null}
    LATEST_VERSION=$(curl -s https://api.github.com/repos/amoylab/unla/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
    curl -sL "https://github.com/amoylab/unla/releases/download/${LATEST_VERSION}/mcp-gateway-linux-amd64" -o mcp-gateway
    chmod +x mcp-gateway
    ```

    **Linux ARM64:**

    ```bash theme={null}
    LATEST_VERSION=$(curl -s https://api.github.com/repos/amoylab/unla/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
    curl -sL "https://github.com/amoylab/unla/releases/download/${LATEST_VERSION}/mcp-gateway-linux-arm64" -o mcp-gateway
    chmod +x mcp-gateway
    ```
  </Step>

  <Step title="启动服务">
    ```bash theme={null}
    ./mcp-gateway
    ```
  </Step>
</Steps>

## 配置说明

### 环境变量文件

下载的 `.env` 文件包含了所有必要的配置项。主要配置包括：

<AccordionGroup>
  <Accordion icon="database" title="数据库配置">
    配置用于存储聊天消息和网关配置的数据库连接信息
  </Accordion>

  <Accordion icon="bell" title="通知配置">
    配置用于配置更新通知的方式（signal、api、redis 等）
  </Accordion>

  <Accordion icon="key" title="认证配置">
    配置 JWT 密钥和超级管理员账户信息
  </Accordion>
</AccordionGroup>

### 配置文件

* `configs/apiserver.yaml`: API 服务器配置
* `configs/mcp-gateway.yaml`: MCP Gateway 核心配置

详细的配置说明请参考[配置文档](/configuration/apiserver)。

## 注意事项

<Warning>
  二进制部署方式需要您自行管理服务的启动、停止和监控。建议在生产环境中使用进程管理工具如 systemd 或 supervisor。
</Warning>

### systemd 服务配置示例

您可以创建 systemd 服务文件来管理 MCP Gateway：

```ini theme={null}
[Unit]
Description=MCP Gateway
After=network.target

[Service]
Type=simple
User=mcpgateway
WorkingDirectory=/opt/unla
ExecStart=/opt/unla/mcp-gateway
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
```

将此文件保存为 `/etc/systemd/system/mcp-gateway.service`，然后：

```bash theme={null}
sudo systemctl daemon-reload
sudo systemctl enable mcp-gateway
sudo systemctl start mcp-gateway
```

### 防火墙配置

确保以下端口可访问：

* `5235`: MCP Gateway 主要服务端口
* `5335`: 管理端口（仅内部访问）

<Tip>
  如需 Web 管理界面，建议同时部署 API Server 和 Web 前端，或使用 [All-in-One Docker 部署](/deployment/docker#all-in-one-部署)方式。
</Tip>
