centos-7.6 安装 kong 和konga
安装kong
配置yum仓库
wget -O /etc/yum.repos.d/kong.repo https://bintray.com/kong/kong-rpm/rpm
vim /etc/yum.repos.d/kong.repo
# tail -n 4 /etc/yum.repos.d/kong.repo
baseurl=https://kong.bintray.com/kong-rpm/centos/7
gpgcheck=0
repo_gpgcheck=0
enabled=1
yum -y install kong-1.1.2
安装并配置数据库
yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7.6-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y
yum install postgresql96 -y
yum install postgresql96-server -y
# 初始化数据库
/usr/pgsql-9.6/bin/postgresql96-setup initdb
# rhel 系6版本系统命令如下
/usr/pgsql-9.6/bin/initdb
# 修改配置文件
vim /var/lib/pgsql/9.6/data/pg_hba.conf
grep -Ev "^$|^#" /var/lib/pgsql/9.6/data/pg_hba.conf
local all all peer
host all all 127.0.0.1/32 trust
host all all ::1/128 ident
host all all 0.0.0.0/0 trust
vim /var/lib/pgsql/9.6/data/postgresql.conf
grep -E "port|listen" /var/lib/pgsql/9.6/data/postgresql.conf
listen_addresses = '*' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
# supported by the operating system:
# supported by the operating system:
# %r = remote host and port
#启动数据库
systemctl enable --now postgresql-9.6
# 新建库和用户
su - postgres
psql
CREATE USER kong WITH PASSWORD '123456';
CREATE DATABASE kong OWNER kong;
GRANT ALL PRIVILEGES ON DATABASE kong to kong;
配置kong
cp /etc/kong/kong.conf.default /etc/kong/kong.conf
vim /etc/kong/kong.conf
grep -E "pg|post" /etc/kong/kong.conf
database = postgres # Determines which of PostgreSQL or Cassandra
# Accepted values are `postgres`,
pg_host = 127.0.0.1 # Host of the Postgres server.
pg_port = 5432 # Port of the Postgres server.
pg_timeout = 5000 # Defines the timeout (in ms), for connecting,
pg_user = kong # Postgres user.
pg_password = 123456 # Postgres user's password.
pg_database = kong # The database name to connect to.
# 初始化数据库
kong migrations bootstrap
kong start
# 检查状态
kong health
nginx.......running
Kong is healthy at /usr/local/kong
安装Konga
安装
curl --silent --location https://rpm.nodesource.com/setup_9.x | bash -
yum install -y nodejs
git clone https://github.com/pantsel/konga.git
cd konga/
npm install --unsafe-perm=true --allow-root
npm i pm2 -g
配置数据库
su - postgres
psql
CREATE USER konga WITH PASSWORD '123456';
CREATE DATABASE konga OWNER konga;
GRANT ALL PRIVILEGES ON DATABASE konga to konga;
编写配置文件
cp .env_example .env
cat .env
PORT=1337
NODE_ENV=production
KONGA_HOOK_TIMEOUT=120000
DB_ADAPTER=postgres
DB_URI=postgresql://konga:123456@localhost:5432/konga
KONGA_LOG_LEVEL=warn
TOKEN_SECRET=some_secret_token
# 创建数据
node ./bin/konga.js prepare --adapter postgres --uri postgresql://localhost:5432/konga
启动
pm2 start npm --name 'konga' -- run production
打开 ip:1337
注册密码要尽量复杂,密码过于简单报错,需要删库重建 ,示例 li@123