centos下kong源码安装

参考资料:

https://docs.konghq.com/install/source/

环境准备:操作系统 centeros7.3

             1 :openssl和pcre一般系统自带,如果没有可自己安装 https://www.openssl.org/source/

               或者 yum -y install pcre-devel openssl openssl-devel

              2: git

                yum install git -y

              3:gcc

                yum install gcc -y

               3: lua

      wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz

            tar -xvf LuaJIT-2.0.5.tar.gz

                  cd LuaJIT-2.0.5

                  make install

一: 下载安装 openresty

    wget https://openresty.org/download/openresty-1.13.6.2.tar.gz

   tar -xvf openresty-1.13.6.2.tar.gz

   cd openresty-1.13.6.2

   ./configure  --with-pcre-jit --with-http_ssl_module  --with-http_realip_module --with-http_stub_status_module  --with-http_v2_module

    gmake install

二:luarocks 

     wget http://luarocks.github.io/luarocks/releases/luarocks-3.0.3.tar.gz

      tar -xvf luarocks-3.0.3.tar.gz

      cd luarocks-3.0.3

       ./configure

      make install

三:安装kong 

       将源码copy到服务器

       make install

       如果成功会提示:kong 0.14.1-0 is now installed in /usr/local (license: MIT)

四 :安装数据库

    yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm -y

    yum install postgresql10 -y

    yum install postgresql10-server -y

    /usr/pgsql-10/bin/postgresql-10-setup initdb

    systemctl enable postgresql-10

     systemctl start postgresql-10

   创建数据库

su - postgres
psql
CREATE USER kong; CREATE DATABASE kong OWNER kong;
\q
exit;

还需要设置下数据库访问权限
vi /var/lib/pgsql/10/data/pg_hba.conf
修改为:host    all             all             127.0.0.1/32            trust
systemctl restart postgresql-10

五:kong启动

在 /etc/kong/ 文件创建kong.conf 内容如下

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 = # The password to authenticate if required.
pg_database = kong

在kong源码根目录
bin/kong migrations up
bin/kong start
检查配置:
curl -i -X GET http://localhost:8001/

安装完毕。

六: kong dashboard
yum install -y nodejs
npm install -g kong-dashboard
nohup kong-dashboard start --kong-url http://0.0.0.0:8001 --basic-auth admin=123456 &
posted on 2018-09-27 22:01  红色十月  阅读(944)  评论(0编辑  收藏  举报