杨健康 發表於 2019-10-11 12:08:00

centos-7.6 安装 kong 和konga

<h1 id="安装kong">安装kong</h1>
<h2 id="配置yum仓库">配置yum仓库</h2>
<pre><code>wget -O /etc/yum.repos.d/kong.repohttps://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

</code></pre>
<h2 id="安装并配置数据库">安装并配置数据库</h2>
<pre><code>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;
</code></pre>
<h2 id="配置kong">配置kong</h2>
<pre><code>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
# 检查状态
konghealth

nginx.......running
Kong is healthy at /usr/local/kong
</code></pre>
<h1 id="安装konga">安装Konga</h1>
<h2 id="安装">安装</h2>
<pre><code>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
</code></pre>
<h2 id="配置数据库">配置数据库</h2>
<pre><code>su - postgres
psql
CREATE USER konga WITH PASSWORD '123456';
CREATE DATABASE konga OWNER konga;
GRANT ALL PRIVILEGES ON DATABASE konga to konga;
</code></pre>
<h2 id="编写配置文件">编写配置文件</h2>
<pre><code>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.jsprepare --adapter postgres --uri postgresql://localhost:5432/konga
</code></pre>
<h2 id="启动">启动</h2>
<pre><code>pm2 start npm --name 'konga'-- run production
</code></pre>
<h2 id="打开--ip1337">打开ip:1337</h2>
<p>注册密码要尽量复杂,密码过于简单报错,需要删库重建,示例li@123</p><br><br>
来源:https://www.cnblogs.com/66li/p/11653408.html
頁: [1]
查看完整版本: centos-7.6 安装 kong 和konga