Search code examples
postgresqlaptkongubuntu-20.04

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


I tried to install using the instructions available on https://docs.konghq.com/install/ubuntu/ and also using snap store but I get the same error. I don't know if it's relevant or not but I am using postgres-12.2 which comes pre-installed with Ubuntu-20.04. The directory structure in postgres-12.2 is different from the earlier ones.

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.sstatic.net/2pzKn.png

Solution

  • Finally, it was done after a lot of research and endless tries. If you face the same issue, follow the following order(For Ubuntu 20.04 only):

    1. Better not install using apt-get or snap(at least until a snap for Ubuntu 20.04 is available). Install using the .deb package available at https://docs.konghq.com/install/ubuntu/#packages. After downloading the package, navigate to the Downloads folder in the terminal and run the following commands to install:

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

      Don't know what the first command is installing but it is suggested to do so as per the official documentation of KONG.

    2. In another terminal, create a new user and database in postgres for KONG connectivity.

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

    3. Back to the terminal where you were installing KONG. Try running the command:

      sudo kong migrations bootstrap

      If everything goes without a glitch, consider yourself lucky and go to step 5.

    4. If there occurs an error at step 3 as: Error: missing password, required for connect, there's more work to be done.

      [You may face trouble creating files and editing them at this step.]

    5. Run the command

      sudo kong start

      to verify the correct configuration. Open your browser and navigate to http://localhost:8001. If some page opens, KONG is correctly configured on your device. Go back to the terminal and stop KONG using the command

      sudo kong stop