>[danger] 本文檔僅針對離線版加密器(`Compiler` 基礎版、高級版、旗艦版),試用版和在線版不需要此操作
# 準備工作
* 需要`x86_64`的`Linux`機器,推薦`CentOS7`系統
* 以`root`權限執行程序(因為獲取硬件的指紋,需要 root 權限)
## 獲取加密機器的 key
安裝前先下載 `gen_key` 工具([下載地址](https://business.swoole.com/static/gen_key)),然后在準備好的機器上執行下面的命令,生成硬件指紋:
```bash
chmod a+x gen_key
./gen_key
```
## 申請授權
進入識沃官網 [https://business.swoole.com/product/get_compiler/](https://business.swoole.com/product/get_compiler/) 點擊 “申請新的軟件包” ,將上一步 `gen_key` 執行輸出的機器 `Key` 填入表單中,并提交。

等待 `1-2` 分鐘后構建完成,就可以下載到軟件包了。
## 安裝加密器
獲取到下載的加密器軟件包后解壓到當前目錄。
* `loader` 子目錄是 `swoole_loader` 擴展,加密后代碼要執行的機器上必須安裝 `swoole_loader` 擴展
* `swoole-compiler30100.deb` :`Ubuntu/Debian` 系統下使用 `dpkg -i` 安裝此軟件
* `swoole-compiler30100.rpm` :`CentOS/RedHat` 系統下使用 `rpm -i` 安裝此軟件
安裝完成后使用 `swoole-compiler30100` 命令加密PHP代碼
```shell
sudo swoole-compiler30100 -h
Swoole Compiler version 3.1.0
命令 :
-h 查看幫助信息
-t type 設置編譯類型為加密代碼或證書,可選值為: code/license,默認值為: code
-c filePath 設置配置文件地址
例子 :
swoole-compiler30100 -h
swoole-compiler30100 -t code -c ~/config.ini
swoole-compiler30100 -t license -c ~/config.ini
```
配置文件 `config.ini` 請參考 [配置文件](%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6.md)