源码编译安装 kong 步骤总结

避免权限问题,测试环境全部使用的是 root 用户操作

1.安装 openresty
wget https://openresty.org/download/openresty-1.15.8.2.tar.gz

获取openresty源码。

./configure \
   --with-pcre-jit \
   --with-http_ssl_module \
   --with-http_realip_module \
   --with-http_stub_status_module \
   --with-http_v2_module
make
make install
# openresty 加入到path
export PATH="$PATH:/usr/local/openresty/bin"

openresty 安装完成。

2.安装 luarocks
wget https://luarocks.org/releases/luarocks-3.2.1.tar.gz

获取 luarocks

./configure --with-lua=/usr/local/openresty/luajit/ \
    --lua-suffix=jit \
    --with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1
make build
make install

需指定 --with-lua 使用openresty的luajit 存在版本差异,openresty 使用的lua版本为5.1。有一个底层库依赖 bitOp 不支持现在的5.3版本

3.下载kong 代码
git clone [email protected]:Kong/kong.git

获取 kong 代码

make install

完成kong 的安装。

遇到的问题
  1. lua 版本问题,在安装 luarocks 时 未指定 --with-lua--with-lua-include 最后在执行 kongmake install 出现版本冲突。无法继续下去。

  2. 系统基础库依赖问题,在安装 lyaml 依赖的时候出现了

    Error: Failed installing dependency: https://luarocks.org/lyaml-6.2.4-1.src.rock - Could not find library file for YAML
      No file libyaml.a in /usr/local/lib
      No file libyaml.a in /usr/local/lib64
      No file libyaml.so in /usr/local/lib
      No file libyaml.so in /usr/local/lib64
      No file matching libyaml.so.* in /usr/local/lib
      No file matching libyaml.so.* in /usr/local/lib64
      No file libyaml.a in /usr/lib
      No file libyaml.a in /usr/lib64
      No file libyaml.so in /usr/lib
      No file libyaml.so in /usr/lib64
      No file matching libyaml.so.* in /usr/lib
      No file matching libyaml.so.* in /usr/lib64
      No file libyaml.a in /lib
      No file libyaml.a in /lib64
      No file libyaml.so in /lib
      No file libyaml.so in /lib64
      No file matching libyaml.so.* in /lib
      No file matching libyaml.so.* in /lib64
    You may have to install YAML in your system and/or pass YAML_DIR or YAML_LIBDIR to the luarocks command.
    

    错误,在 centos 系统上安装了 libyamllibyaml-devel 后,再执行 kongmake install

kong 1.4.0-0 is now installed in /usr/local (license: Apache 2.0)

安装完成。

我的博客即将同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=1suums4p513oq

你可能感兴趣的:(源码编译安装 kong 步骤总结)