APISIX Dashboard 源码构建

本文档详细介绍了如何在腾讯云CentOS7.9环境中,从源码构建Apache APISIX Dashboard,包括Golang和Node.js的安装,Yarn的配置,以及构建、启动和管理服务的步骤。最后,提供了使用Systemd服务管理器的配置和服务启动方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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:

  1. 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:

  1. 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
  1. Yarn
# 设置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

  1. After the build is complete and before you start, make sure the following dependencies are installed and running in your environment.
  1. Check and modify the configuration information in output/conf/conf.yaml according to your deployment environment.
  2. Launch the Dashboard
cd ./output
./manager-api
  1. Without changing the configuration, visit http://127.0.0.1:9000 to use the dashboard with GUI, where the default username and password are admin.

Service

使用源代码编译方法进行部署时,需要处理自己的服务管理。我们为使用 Systemd 服务管理器的操作系统提供服务文件模板。

  1. 安装
cp -rf /usr/local/apisix-dashboard/output/* /usr/local/apisix-dashboard
  1. 创建服务单元

复制以下或者直接使用这个文件,需要复制到/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
  1. 管理服务

您可以使用以下命令来管理服务。

# 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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值