安装依赖:
# install epel, `luarocks` need it.
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh epel-release-latest-7.noarch.rpm
# add OpenResty source
sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
# install OpenResty, etcd and some compilation tools
sudo yum install -y etcd openresty curl git gcc luarocks lua-devel
# start etcd server
sudo service etcd start
安装 apisix:
sudo yum install -y https://github.com/apache/incubator-apisix/releases/download/1.3/apisix-1.3-0.el7.noarch.rpm
启动 apisix:
sudo apisix start
检查是否正常运行:
ps aux|grep apisix
netstat -lntp | grep 9080
可选:修改 /user/local/apisix/conf/config.yaml
的 apisix.admin_key:
apisix:
# ... ...
admin_key
-
name: "admin"
key: abcdefghabcdefgh
role: admin
curl http://127.0.0.1:9080/apisix/admin/routes?api_key=abcdefghabcdefgh -i
HTTP/1.1 200 OK
Date: Fri, 28 Feb 2020 07:48:04 GMT
Content-Type: text/plain
... ...
{"node":{...},"action":"get"}
也可以不更改,直接使用默认的 api_key:
curl http://127.0.0.1:9080/apisix/admin/routes?api_key=edd1c9f034335f136f87ad84b625c8f1 -i
访问 APISIX Dashboard(http://localhost:9080/apisix/dashboard)。
注意:如果访问 Dashboard 出现 403,需要修改 /user/local/apisix/conf/config.yaml
中的 allow_admin
字段,增加访问机器的 IP 地址,如果不知道 IP 地址,可以查看 /usr/local/apisix/logs/error.log
日志,该日志会记录访问机器的 IP 地址。
网友评论