1.docker安裝etcd
docker run -it -p 2379:2379 --env ALLOW_NONE_AUTHENTICATION=yes -d bitnami/etcd
2.安裝apisix
docker run -v /config.yaml:/usr/local/apisix/conf/config.yaml -p 9080:9080 -d apache/apisix
修改配置文件對應的ip
apisix:
node_listen: 9080 # APISIX listening port
enable_ipv6: false
allow_admin: # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
- 0.0.0.0/0 # We need to restrict ip access rules for security. 0.0.0.0/0 is for test.
admin_key:
- name: "admin"
key: edd1c9f034335f136f87ad84b625c8f1
role: admin # admin: manage all configuration data
# viewer: only can view configuration data
- name: "viewer"
key: 4054f7cf07e344346cd3f287985e76a2
role: viewer
etcd:
host: # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
- "http://192.168.211.130:2379" # multiple etcd address
prefix: "/apisix" # apisix configurations prefix
timeout: 30 # 30 seconds
3.安裝apisix-dashboard
docker run -d -p 9000:9000 -v /conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml apisix-dashboard
修改配置文件

遇到ip adress not allowed的問題
解決:修改allow_list對應本機網關
通過源碼編譯鏡像
1.編譯apisix需要安裝luarocks依賴
$wget http://luarocks.org/releases/luarocks-3.7.0.tar.gz
2.解壓縮tar -xzvf luarocks-3.7.0.tar.gz
3.cd luarocks-3.7.0/
4…/configure --prefix=/usr/local/openresty/luajit \ 安裝到此目錄下
–with-lua=/usr/local/openresty/luajit/
–lua-suffix=jit
–with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1
然后找到
在
其中,
lua
安裝路徑下的
lua.h
的位置,即
find / -name "lua.h"
,我的路徑是
usr/local/lua/src/lua.h
在
usr/local/luarocks
下執行
./configure --prefix=/usr/local/luarocks --with-lua-include=/usr/local/lua/src
其中,
predix
是指定LuaRocks 安裝路徑,
with-lua-include
指定lua文件位置,默認為
$LUA_DIR/include
5. make build
6. sudo make install
7. vi ~/.bash_profile
8. export PATH=$PATH:/usr/local/openresty/luajit/bin 將此項添加進去
9. source /etc/profile
10. reboot
11.luarocks查看是否安裝成功