安裝依賴:
# 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
檢查是否正常運(yùn)行:
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"}
也可以不更改,直接使用默認(rèn)的 api_key:
curl http://127.0.0.1:9080/apisix/admin/routes?api_key=edd1c9f034335f136f87ad84b625c8f1 -i
訪問 APISIX Dashboard(http://localhost:9080/apisix/dashboard)。
注意:如果訪問 Dashboard 出現(xiàn) 403,需要修改 /user/local/apisix/conf/config.yaml 中的 allow_admin 字段,增加訪問機(jī)器的 IP 地址,如果不知道 IP 地址,可以查看 /usr/local/apisix/logs/error.log 日志,該日志會記錄訪問機(jī)器的 IP 地址。