APISIX Dashboard 源码构建
注:此文档构建环境为腾讯云CentOS 7.9,虚拟机同样适用。
Source
The Dashboard project contains both manager-api
and web
, but web
is optional.
The manager-api
and web
will be included in this build guide product.
Prerequisites
Before using source codes to build, make sure that the following dependencies are installed in your environment.
For manager-api
:
- Golang 1.13+
cd /usr/local && wget https://dl.google.com/go/go1.13.linux-amd64.tar.gz
tar -zxvf go1.13.linux-amd64.tar.gz && rm -f go1.13.linux-amd64.tar.gz
# 添加环境变量
sudo vim /etc/profile
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
source /etc/profile
#查看Go版本
go version
Tip: For users in mainland China, you can use the following command to speed up the module downloads.
go env -w GOPROXY=https://goproxy.cn,direct
For web
:
- Node.js current LTS (14.x+)
# 用命令行形式进行下载
cd /usr/local && wget https://nodejs.org/dist/v14.15.4/node-v14.15.4-linux-x64.tar.xz
# 解压缩
tar -xvf node-v14.15.4-linux-x64.tar.xz && rm -f node-v14.15.4-linux-x64.tar.xz
mkdir -p nodejs
mv node-v14.15.4-linux-x64/* /usr/local/nodejs/
# 建立 node&npm 软链接
ln -s /usr/local/nodejs/bin/node /usr/local/bin
ln -s /usr/local/nodejs/bin/npm /usr/local/bin
# 设置国内淘宝镜像源
npm config set registry https://registry.npm.taobao.org
# 查看设置信息
npm config list
# 验证
node -v
npm -v
# 设置Yarn仓库
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install -y yarn
# 设置国内镜像加速
yarn config set registry https://registry.npm.taobao.org
yarn --version
Download
# 如果克隆的太慢,可以直接去官网下载zip包
cd /usr/local && git clone -b release/2.10 https://github.com/apache/apisix-dashboard.git
Build
cd apisix-dashboard
make build
When the build is complete, the results are stored in the root output
directory.
Note: make build
will build manager-api
and web
, use the make help
command to see more commands.
Launch
- After the build is complete and before you start, make sure the following dependencies are installed and running in your environment.
- etcd 3.4.0+
- Check and modify the configuration information in
output/conf/conf.yaml
according to your deployment environment. - Launch the Dashboard
cd ./output
./manager-api
- Without changing the configuration, visit
http://127.0.0.1:9000
to use the dashboard with GUI, where the default username and password areadmin
.
Service
使用源代码编译方法进行部署时,需要处理自己的服务管理。我们为使用 Systemd 服务管理器的操作系统提供服务文件模板。
- 安装
cp -rf /usr/local/apisix-dashboard/output/* /usr/local/apisix-dashboard
- 创建服务单元
复制以下或者直接使用这个文件,需要复制到/usr/lib/systemd/system
目录下执行systemctl daemon-reload
命令。
# copy service unit
cp ./api/service/apisix-dashboard.service /usr/lib/systemd/system/apisix-dashboard.service
systemctl daemon-reload
# or: If you need to modify the service unit, you can use the following command
echo "[Unit]
Description=apisix-dashboard
Conflicts=apisix-dashboard.service
After=network-online.target
[Service]
WorkingDirectory=/usr/local/apisix-dashboard
ExecStart=/usr/local/apisix-dashboard/manager-api -c /usr/local/apisix-dashboard/conf/conf.yaml" > /usr/lib/systemd/system/apisix-dashboard.service
- 管理服务
您可以使用以下命令来管理服务。
# start apisix-dashboard
systemctl start apisix-dashboard
# stop apisix-dashboard
systemctl stop apisix-dashboard
# check apisix-dashboard status
systemctl status apisix-dashboard
Test
浏览器输入:http://:9000,访问Web页面,如果报错:
{"Code":20002,"Message":"IP address not allowed","Data":null,"SourceSrv":""}
默认情况下,127.0.0.0/24
允许访问的 IPv4 范围APISIX Dashboard
。如果要允许所有IPv4访问,那么只需conf.allow_list
在配置文件中conf/conf.yaml
进行如下配置:
vim /usr/local/apisix-dashboard/conf/conf.yaml
conf:
allow_list:
- 0.0.0.0/0