Kong source code installation

Keywords: Programming OpenSSL SSL yum zlib


Kong is a cloud-native, fast, scalable, and distributed Microservice API Gateway


Although Kong has reached 2.0, because the previous expansion development was based on Kong 1.2.1, the source code and development environment construction of Kong are based on Version 1.2.1. The subsequent versions can follow this process, but the versions of each component are different.

Dependent version

0. kong's extension based on 1.2.1

1. openresty

2. luarocks 2.4.3


Installation dependency


Install yaml package ` Yum install libyaml-devel.x86 ʄ`

If there is no yaml package, an error will be reported when executing ` / data / APP / lualocks / bin / lualocks make ` compile kong:

Error: Failed installing dependency: https://luarocks.org/lyaml-6.2.3-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

You may have to install YAML in your system and/or pass YAML_DIR or YAML_LIBDIR to the luarocks command.

Example: luarocks install lyaml YAML_DIR=/usr/local

Install openssl

Download openssl source code to decompress

Using openssl 1.1.0l, you need to change the version of luao SSL in kong dependency to: 20190612 (luao SSL depends on openssl, so you must install the corresponding openssl first)

cd /data/server/kong

wget https://www.openssl.org/source/openssl-1.1.0l.tar.gz

tar -xf openssl-1.1.0l.tar.gz

root User installation openssl

cd openssl-1.1.0l

./config shared zlib

make & make install

mv /usr/bin/openssl /usr/bin/openssl.bak

find / -name openssl

ln -s /usr/local/bin/openssl /usr/bin/openssl

echo "/usr/local/lib64/" >> /etc/ld.so.conf


openssl version -a


Test openssl installation results

openssl version -a

//Output the following

OpenSSL 1.1.0l 10 Sep 2019

built on: reproducible build, date unspecified

platform: linux-x86_64


Install openresty

Download, compile and install Openresty

wget https://openresty.org/download/openresty-

./configure \

  --with-pcre-jit \

  --with-ipv6 \

  --with-http_realip_module \

  --with-http_ssl_module \

  --with-http_stub_status_module \

  --with-http_v2_module \

  --prefix=/data/app/openresty \


Modify environment variables

vi ~/.bash_profile

export PATH="$PATH:/data/app/openresty/bin"
export PATH="$PATH:/data/app/openresty/luajit/lib"
export PATH="$PATH:/data/app/openresty/luajit/include/luajit-2.1"

source ~/.bash_profile 


Install lualocks

Download, compile and install luarocks

wget https://github.com/luarocks/luarocks/archive/2.4.3.zip

./configure \

  --lua-suffix=jit \

  --prefix=/data/app/luarocks \

  --with-lua=/data/app/openresty/luajit \


make build

make install


Modify environment variables

vi ~/.bash_profile

export PATH="$PATH:/data/app/luarocks/bin"

export LUA_PATH="/data/app/luarocks/share/lua/5.1/?.lua"

source ~/.bash_profile 


Compiling and installing kong

Upload the source code of kong, or download the official source code

Unzip, enter the source root directory, and execute '/ data / APP / lualocks / bin / lualocks make'`

Final output indicates successful installation

kong 1.2.1-0 is now installed in /data/app/luarocks (license: Apache 2.0)

Modify another environment variable

export PATH="$PATH:/data/server/kong/kong/bin"


Modify configuration

Modify the configuration file as needed to start the service

Initialize environment

The first time you use Kong, you need to initialize the environment. Initialization is mainly to create core tables in the database and insert data.

Start service

Start the service through bin/kong start -c kong.conf.

Posted by rxsid on Sun, 17 May 2020 08:26:34 -0700