如何在 Ubuntu 20.04 上安装 Kong (https://konghq.com/)?

How to install Kong (https://konghq.com/) on Ubuntu 20.04?

我尝试使用 https://docs.konghq.com/install/ubuntu/ 上的说明进行安装,也尝试使用 snap store,但我遇到了同样的错误。我不知道它是否相关,但我使用的是预装了 Ubuntu-20.04 的 postgres-12.2。 postgres-12.2 中的目录结构与之前的有所不同

error: cannot perform the following tasks:
- Run install hook of "kong" snap if present (run hook "install": 
-----
The files belonging to this database system will be owned by user "snap_daemon".
This user must also own the server process.

The database cluster will be initialized with locale "C.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /var/snap/kong/172/postgresql/10/main ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Asia/Kolkata
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /snap/kong/172/usr/lib/postgresql/10/bin/pg_ctl -D /var/snap/kong/172/postgresql/10/main -l logfile start

createuser: could not connect to database postgres: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/snap/kong/common/sockets/.s.PGSQL.5432"?
-----)```
  [1]: https://i.stack.imgur.com/2pzKn.png

经过大量研究和无数次尝试,终于完成了。如果您遇到同样的问题,请按照以下顺序(仅适用于 Ubuntu 20.04):

  1. 最好不要使用 apt-get 或 snap 安装(至少在 Ubuntu 20.04 的 snap 可用之前)。使用 https://docs.konghq.com/install/ubuntu/#packages 上提供的 .deb 包进行安装。下载包后,导航到终端中的下载文件夹并运行以下命令进行安装:

    sudo apt-get install openssl libpcre3 procps perl
    sudo dpkg -i kong-2.0.4.*.deb

    不知道第一个命令安装的是什么,建议按照KONG官方文档安装。

  2. 在另一个终端中,在 postgres 中为 KONG 连接创建一个新用户和数据库。

    sudo -i -u postgres
    psql
    CREATE USER kong;
    CREATE DATABASE kong OWNER kong;

  3. 回到你安装KONG的终端。尝试 运行ning 命令:

    sudo kong migrations bootstrap

    如果一切顺利,请认为自己很幸运,然后转到第 5 步。

  4. 如果第 3 步出现错误: Error: missing password, required for connect,还有更多工作要做。

    [您可能会在这一步创建和编辑文件时遇到问题。]

  5. 运行命令

    sudo kong start

    验证配置是否正确。打开浏览器并导航至 http://localhost:8001。如果某些页面打开,则 KONG 已在您的设备上正确配置。返回终端并使用命令

    停止 KONG

    sudo kong stop