Ubuntu 18.04安装kong

本人是Ubuntu 18.04 操作系统,按照一步步执行下来没有任何问题。

首先安装postgresql数据库
安装postgresql
sudo apt update
sudo apt install postgresql postgresql-contrib

修改配置,使本地用账号密码连接数据库,编辑/etc/postgresql/10/main/pg_hba.conf (把10替换成你的版本号)
将 local all postgres peer 最后的peer改成trust
将 local all all peer 最后的peer改成trust

重启postgres
sudo service postgresql restart

以默认账号postgres 连接数据库,进入psql控制台,用\q 命令可以退出
psql -U postgres

创建kong用户和kong数据库
create user kong with password 'kong';
create database kong owner kong;

安装kong
按照kong官方文档执行

sudo apt-get update
sudo apt-get install -y apt-transport-https curl lsb-core
echo "deb https://kong.bintray.com/kong-deb `lsb_release -sc` main" | sudo tee -a /etc/apt/sources.list
curl -o bintray.key https://bintray.com/user/downloadSubjectPublicKey?username=bintray
sudo apt-key add bintray.key
sudo apt-get update
sudo apt-get install -y kong

修改配置文件:
sudo nano /usr/local/share/lua/5.1/kong/templates/kong_defaults.lua
把pg_password = NONE 改成 pg_password = kong

kong migrations bootstrap

初始化kong数据库(否则会报错)

Error: /usr/local/share/lua/5.1/kong/cmd/utils/migrations.lua:16: Database needs bootstrapping or is older than Kong 1.0.

To start a new installation from scratch, run 'kong migrations bootstrap'.

To migrate from a version older than 1.0, migrated to Kong 1.5.0 first. 
If you still have 'apis' entities, you can convert them to Routes and Services
using the 'kong migrations migrate-apis' command in Kong 1.5.0.

kong migrations bootstrap

启动kong
sudo kong start

全部搞定。

你可能感兴趣的:(kong)