wget https://www.cpan.org/src/5.0/perl-5.28.0.tar.gz tar -zxvf perl-5.28.0.tar.gz cd perl-5.28.0 ./Configure -des -Dprefix=$HOME/localperl make make test make install
export PATH="$PATH:/root/localperl/bin"
安装openssl 1.1.1f
1 2 3 4 5
wget https://www.openssl.org/source/openssl-1.1.1f.tar.gz tar -zxvf openssl-1.1.1f.tar.gz cd openssl-1.1.1f ./config --prefix=/usr/local/openssl no-zlib make && make install
yum install -y libyaml libyaml-devel git 跳转到kong源码目录 进行make安装 cd kong make install
如果成功会提示:kong 2.0.3-0 is now installed in /usr/local (license: Apache 2.0)
启动kong
export PATH=”$PATH:/usr/local/openresty/bin”
在 /etc/kong/ 文件创建kong.conf 内容如下
1 2 3 4 5 6 7 8 9 10 11
# kong 安装目录 prefix = /usr/data/kong/ proxy_listen = 0.0.0.0:8000, 0.0.0.0:8443 ssl admin_listen = 127.0.0.1:8001 database = postgres # Determines which of PostgreSQL or Cassandra
pg_host = 127.0.0.1 # The PostgreSQL host to connect to. pg_port = 5432 # The port to connect to. pg_user = kong # The username to authenticate if required. pg_password = 123456 # The password to authenticate if required. pg_database = kong
如果缺少lua-kong-nginx-module模块会导致启动时出现下面的报错 Error: module ‘resty.kong.tls’ not found:No LuaRocks module found for resty.kong.tls no field package.preload[‘resty.kong.tls’] 使用find命令在根目录下找kong缺失的模块文件(如:find / -name tls.lua),将找到后的模块文件放到kong启动加载时检索的目录下,或使用建立软连接的方式即可 创建文件夹 mkdir /usr/local/share/lua/5.1/resty/kong 拷贝lua-kong-nginx-module里的/root/lua-kong-nginx-module-0.0.6/lualib/resty/kong 到 /usr/local/share/lua/5.1/resty/kong
2020/04/13 15:45:53 [verbose] Kong: 2.0.3 2020/04/13 15:45:53 [verbose] reading config file at /etc/kong/kong.conf 2020/04/13 15:45:53 [verbose] prefix in use: /usr/data/kong 2020/04/13 15:45:53 [verbose] retrieving database schema state... 2020/04/13 15:45:53 [verbose] schema state retrieved 2020/04/13 15:45:53 [verbose] preparing nginx prefix directory at /usr/data/kong 2020/04/13 15:45:53 [info] prefix directory /usr/data/kong not found, trying to create it 2020/04/13 15:45:53 [verbose] SSL enabled, no custom certificate set: using default certificate 2020/04/13 15:45:53 [verbose] generating default SSL certificate and key 2020/04/13 15:45:53 [warn] ulimit is currently set to "1024". For better performance set it to at least "4096" using "ulimit -n" 2020/04/13 15:46:01 [verbose] could not start Kong, stopping services 2020/04/13 15:46:01 [verbose] stopped services Error: ./kong/cmd/start.lua:75: ./kong/cmd/start.lua:64: nginx: [error] init_by_lua error: error loading module '_openssl.hmac' from file '/usr/local/lib/lua/5.1/_openssl.so': /usr/local/lib/lua/5.1/_openssl.so: undefined symbol: SSL_CTX_set1_cert_store stack traceback: [C]: at 0x7f0535100ff0 [C]: in function 'require' /usr/local/share/lua/5.1/openssl/hmac.lua:1: in main chunk [C]: in function 'require' /usr/local/share/lua/5.1/lapis/util/encoding.lua:3: in main chunk [C]: in function 'require' /usr/local/share/lua/5.1/lapis/session.lua:4: in main chunk [C]: in function 'require' /usr/local/share/lua/5.1/lapis/request.lua:3: in main chunk [C]: in function 'require' /usr/local/share/lua/5.1/lapis/application.lua:25: in main chunk [C]: in function 'require' /usr/local/share/lua/5.1/lapis/init.lua:1: in main chunk [C]: in function 'require' ./kong/init.lua:71: in main chunk [C]: in function 'require' init_by_lua:2: in main chunk
stack traceback: [C]: in function 'error' ./kong/cmd/start.lua:75: in function 'cmd_exec' ./kong/cmd/init.lua:88: in function <./kong/cmd/init.lua:88> [C]: in function 'xpcall' ./kong/cmd/init.lua:88: in function <./kong/cmd/init.lua:45> bin/kong:9: in function 'file_gen' init_worker_by_lua:47: in function <init_worker_by_lua:45> [C]: in function 'xpcall' init_worker_by_lua:54: in function <init_worker_by_lua:52>