安裝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