參考資料: https://docs.konghq.com/install/source/ 環境準備:操作系統 centeros7.3 1 :openssl和pcre一般系統自帶,如果沒有可自己安裝 https://www.openssl.org/source/ 或者 yum -y install ...
參考資料:
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 &