# 快速部署 - \[宝塔]

{% hint style="info" %}
本教程需要面板程序<mark style="color:green;">**`版本>2.7.0`**</mark>方可使用！
{% endhint %}

## 一丶部署环境 <a href="#install-bt" id="install-bt"></a>

### 1.1 部署宝塔 <a href="#install-bt" id="install-bt"></a>

> 请依据系统与环境选择对应一键脚本：<https://www.bt.cn/bbs/thread-19376-1-1.html>

### 1.2 安装环境 <a href="#install-environment" id="install-environment"></a>

* 环境安装要求，请参考 => [面板要求](https://proxypanel.gitbook.io/wiki/#requirements)
* Tips: 软件版本在面板支持的情况下，尽可能挑选<mark style="color:green;">**最新**</mark>的<mark style="color:green;">**稳定**</mark>版本用于生产环境；
* MySQL 数据库可以不安装在和面板同一机器上，可以选择云服务商的数据库进行托管或者在其他服务器安装进行分离使用；

<figure><img src="/files/6wmElljkwUf4z7zkdfkm" alt=""><figcaption><p>4款面板需要的软件</p></figcaption></figure>

### 1.3 配置PHP <a href="#config-php" id="config-php"></a>

#### 1.3.1 安装扩展 <a href="#install-php-extension" id="install-php-extension"></a>

* fileinfo
* redis
* opcache （可选，推荐安装）

<figure><img src="/files/MtwqGy9b1t5oacvMv1wN" alt=""><figcaption><p>面板需要的2个PHP扩展</p></figcaption></figure>

#### 1.3.2 移除 \[禁用函数] <a href="#enable-php-functions" id="enable-php-functions"></a>

* putenv
* pcntl\_*alarm*
* *pcntl\_signal*
* *symlink*
* *proc\_开头函数*

<figure><img src="/files/gE5jdBs69xKIdIh20Zm9" alt=""><figcaption><p>删除禁用函数页面</p></figcaption></figure>

#### 1.3.3 推荐优化 <a href="#optimize-php" id="optimize-php"></a>

根据服务器的内存大小，适量的增加php配置中memory\_limit的值

<figure><img src="/files/MEYaMtwhpfkSzkaH1lqP" alt=""><figcaption><p>优化php的内存</p></figcaption></figure>

## 二丶部署面板网站 <a href="#deploy-website" id="deploy-website"></a>

### 2.1 创建网站 和 数据库 <a href="#create-website" id="create-website"></a>

* 添加网站时，输入你要用的`域名`，同时创建数据库； 数据库`MySQL`   `utf8mb4`

![站点信息](/files/-MJkB8th5Wc23prDU_Gr)

* 记住自己&#x7684;**`数据库名`**，**`用户名`**&#x548C;**`密码`**！

![返回信息](/files/-MJkBP1I-hmR3BIZ6xoP)

![网站目录](/files/-MJkEdwFXFfQlpZy60Tv)

### 2.2 下载面板程序 <a href="#download-panel" id="download-panel"></a>

{% hint style="info" %}
生产环境下，请优先使用 <mark style="color:green;">**Release版本**</mark>
{% endhint %}

|    版本   | 简介                                                                  |
| :-----: | ------------------------------------------------------------------- |
|  Master | 最新版本，如果你想提前尝鲜新功能，可以使用本版本！同时你也可以通过我们提供的Demo站点来测试新版本，来加速我们推出Release版本 |
| Release | 稳定版本，每当Master版本稳定以后都会不定期推出的版本                                       |

#### Master版 <a href="#download-master" id="download-master"></a>

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash">cd /www/wwwroot/你的域名
# 例：cd /www/wwwroot/demo.proxypanel.ml
<strong>
</strong><strong>git clone https://github.com/ProxyPanel/ProxyPanel.git tmp &#x26;&#x26; cp -r tmp/. . &#x26;&#x26; rm -rf tmp/
</strong></code></pre>

#### Release版 <a href="#download-release" id="download-release"></a>

前往 GitHub 下载 [Release版](https://github.com/ProxyPanel/ProxyPanel/releases)

1. 下载任一压缩文件

<div align="center"><img src="/files/-MJkJCtTsf3Lq8SzE5u8" alt="下载文件"></div>

2\. 上传压缩包至网站根目录并解压

![上传文件](/files/-MJkJi1FXzp-mqZHnihw)

3\. 解压完毕后，可以删除压缩包

![解压](/files/-MJkKKPRmwcpgJItKf-7)

4\. 将文件从ProxyPanel-xxx文件夹中剪切至域名根部文件夹，并删除ProxyPanel-xxx

![最终面板文件](/files/-MJkLabXBkSUah0SGJRe)

### 2.3 设置网站 <a href="#config-web" id="config-web"></a>

以下内容，为宝塔面板设置

#### 2.3.1 设置运行目录

站点管理-网站目录-运行目录至pubilc 和 取消防跨站攻击 并保存

<figure><img src="/files/yw8QExjS19NgyTAdopKe" alt=""><figcaption></figcaption></figure>

#### 2.3.2 设置伪静态

伪静态 - 选择laravel5；或者输入 并保存

```
location / {
    try_files $uri $uri/ /index.php?$query_string;
}
```

![设置伪静态](/files/-MJkPaHJ1pmTZoWYJHn3)

#### 2.3.3 设置SSL （可选）

SSL - 申请SSL （可开启 **强制HTTPS**）

![](/files/-MJkQ60Qy6fJPS1rAvfc)

## 三丶部署面板 <a href="#deploy-panel" id="deploy-panel"></a>

SSH登入，进入网站根部文件夹

```shell
cd /www/wwwroot/你的域名
例：cd /www/wwwroot/demo.proxypanel.ml
```

再运行以下代码安装面板

```shell
sh install.sh
```

### 3.1 设置 广播 Reverb <a href="#reverb" id="reverb"></a>

{% hint style="info" %}
【广播】 应用于内容的实时同步，目前用于用户支付结果查询，管理节点页面节点连通性，地理位置更新，重启结果等，需要内容实时在页面显示的场景。
{% endhint %}

大致步骤：

1. 编辑目录下 `.env` 文件中 REVERB\_ 开头参数；
2. 清理缓存  `php artisan optimize:clear && php artisan optimize`
3. 重新编译前端js和重启reverb，`npm run build && supervisorctl restart reverb`
4. 添加/修改网站nginx配置文件<br>

   <pre class="language-nginx" data-line-numbers data-full-width="false"><code class="lang-nginx">server {
       ...

   <strong>    location / {
   </strong>        proxy_http_version 1.1;
           proxy_set_header Host $http_host;
           proxy_set_header Scheme $scheme;
           proxy_set_header SERVER_PORT $server_port;
           proxy_set_header REMOTE_ADDR $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "Upgrade";

   <strong>        proxy_pass http://0.0.0.0:8080;
   </strong>    }

       ...
   }
   </code></pre>

#### 通用修改/存在参数

| env参数               | 值                   |
| ------------------- | ------------------- |
| BROADCAST\_DRIVER   | `reverb`            |
| REVERB\_APP\_ID     | 随机数字id              |
| REVERB\_APP\_KEY    | 随机字符串               |
| REVERB\_APP\_SECRET | 随机字符串               |
| REVERB\_SCHEME      | 可选，值为`http`/`https` |

{% hint style="success" %}
以下配置按照自生需求选<mark style="color:$danger;">一个</mark>配置
{% endhint %}

<h4 align="center"><mark style="color:$primary;">方案A 广播使用与面板同子域名</mark></h4>

通知和面板都是使用：proxypanel.ddo.jp；← 域名是为了方便理解使用的案例

* 配置env，REVERB\_PATH， 用于分流正常访问和通知访问；

|              | 作用                                                        | 备注                  |
| ------------ | --------------------------------------------------------- | ------------------- |
| REVERB\_PATH | Reverb 服务器期望接收连接的 URL 路径。在您的配置中为 `REVERB_PATH=`，表示没有路径前缀。 | 例如：`/eventcastsing` |
| REVERB\_HOST |                                                           | proxypanel.ddo.jp   |

```bash
REVERB_APP_ID=510141
REVERB_APP_KEY=ti12342lbcrgjzazvua6
REVERB_APP_SECRET=kvjczliy123hrylnh56z
REVERB_SCHEME=https
REVERB_HOST=proxypanel.ddo.jp
REVERB_PATH=/eventcastsing

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
VITE_REVERB_PATH="${REVERB_PATH}"
REVERB_SERVER_PATH="${REVERB_PATH}"
```

修改nginx配置中第4行需要按照REVERB\_PATH值修改

<pre class="language-nginx" data-overflow="wrap" data-line-numbers><code class="lang-nginx">server {
    ...

<strong>    location /eventcastsing/ {
</strong>        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Scheme $scheme;
        proxy_set_header SERVER_PORT $server_port;
        proxy_set_header REMOTE_ADDR $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";

        proxy_pass http://0.0.0.0:8080;
    }

    ...
}
</code></pre>

***

<h4 align="center"><mark style="color:$primary;">方案B 广播使用与面板使用不同子域名</mark></h4>

* 面板使用：proxypanel.ddo.jp；← 域名是为了方便理解使用的案例
  * 通知使用：b.ddo.jp 或者 proxypanel.work.gd
* 配置env，REVERB\_HOST；

|              | 作用 | 备注                 |
| ------------ | -- | ------------------ |
| REVERB\_HOST |    | proxypanel.work.gd |

```bash
REVERB_APP_ID=510141
REVERB_APP_KEY=ti12342lbcrgjzazvua6
REVERB_APP_SECRET=kvjczliy123hrylnh56z
REVERB_SCHEME=https
REVERB_HOST=proxypanel.work.gd
REVERB_PATH=

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
VITE_REVERB_PATH="${REVERB_PATH}"
REVERB_SERVER_PATH="${REVERB_PATH}"
```

## 四丶更多设置&优化（可选） <a href="#optimize" id="optimize"></a>

### 4.1 设置

{% hint style="info" %}
每次修改 `.env` 后，请运行以下代码，重新预加载必要文件\
SSH：在网站根目录下，运行以下代码；Laravel 自带缓存常用内容来优化面板运行。

```sh
php artisan optimize
```

{% endhint %}

在面板文件中，编辑 `.env`

![](/files/-MJkWS787Yl8pGi_6X8a)

### 4.2 设置邮件

```
MAIL_DRIVER=smtp #或使用 mailgun
# SMTP设置
MAIL_HOST=smtp.exmail.qq.com
MAIL_PORT=465 #SMTP端口
MAIL_USERNAME=admin@proxypanel.ml #使用的邮箱地址
MAIL_PASSWORD=password #SMTP授权码
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=admin@proxypanel.ml #用户看到的发件人邮箱地址
MAIL_FROM_NAME=ProxyPanel #发件人名称

# Mailgun设置
MAILGUN_DOMAIN=
MAILGUN_SECRET=
```

## 五丶后续面板更新/升级 <a href="#update" id="update"></a>

#### Master版 <a href="#master-update" id="master-update"></a>

参考 [升级指南](https://proxypanel.gitbook.io/wiki/upgrade-guide)

#### Release版 <a href="#update-release" id="update-release"></a>

下载最新的压缩包，重新安装


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://proxypanel.gitbook.io/wiki/deploy/bt_light.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
