安裝openresty
tar xzvf openssl-1.0.2h.tar.gz
官方安裝指引:https://openresty.org/cn/installation.html
以下是我個人安裝流程
tar xzvf openresty-1.9.15.1.tar.gz
安裝openresty前需要先 準備對應(yīng)的庫有: perl 5.6.1+, libreadline, libpcre, libssl
如果為ubuntu用戶則
apt-get install libreadline-dev libncurses5-dev libpcre3-dev \
libssl-dev perl make build-essential
下載完畢后進入目錄
./configure \
--prefix=/opt/openresty \
--with-openssl=../openssl-1.0.2h \
--with-pcre-jit \
--with-ipv6 \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_stub_status_module
其中 --prefix=/opt/openresty 為安裝目錄
make
make install
$ export PATH="/opt/openresty/bin:/opt/openresty/nginx/sbin:$PATH"
nginx -v
nginx version: openresty/1.9.15.1
表示成功安裝
安裝luarocks
luarocks為lua的包管理工具
1.克隆源碼
git clone https://github.com/keplerproject/luarocks.git
2.配置、編譯、安裝
./configure \
--lua-suffix=jit \
--with-lua=/opt/openresty/luajit \
--with-lua-include=/opt/openresty/luajit/include/luajit-2.1
make
make install
安裝serf v0.7
下載地址 https://www.serf.io/downloads.html
解壓后移到 /usr/local/bin 或者 /usr/bin 目錄下
安裝 Kong
1.克隆源碼并安裝
$ git clone https://github.com/Mashape/kong
$ git checkout next
$ luarocks make
$ cd bin
$ sudo cp kong /usr/local/bin
2.修改配置文件
在源碼的根目錄下有個 kong.conf.default 文件,修改里面對應(yīng)的配置使其滿足你的需要。
運行 Kong
KONG_DATABASE=postgres kong start -c /etc/kong/kong.conf