Home About Me

Installing Kong on Ubuntu: From Package to First API Request

Kong 1.3.0 ships as Ubuntu .deb packages for several releases:

<table> <thead> <tr> <th>Ubuntu release</th> <th>Package</th> </tr> </thead> <tbody> <tr> <td>12.04 Precise</td> <td>kong-1.3.0.precise.amd64.deb</td> </tr> <tr> <td>14.04 Trusty</td> <td>kong-1.3.0.trusty.amd64.deb</td> </tr> <tr> <td>16.04 Xenial</td> <td>kong-1.3.0.xenial.amd64.deb</td> </tr> <tr> <td>17.04 Zesty</td> <td>kong-1.3.0.zesty.amd64.deb</td> </tr> <tr> <td>18.04 Bionic</td> <td>kong-1.3.0.bionic.amd64.deb</td> </tr> </tbody> </table>

Enterprise trial users should take the package from their welcome email. Once the package installation step is done, place the license at /etc/kong/license.json.

You can install from the downloaded package or add Kong's APT repository. For the repository route, set the distribution to the output of lsb_release -sc (for example, precise) and the component to main.

Install from a downloaded package

$ sudo apt-get update
$ sudo apt-get install openssl libpcre3 procps perl
$ sudo dpkg -i kong-1.3.0.*.deb

Install from the APT repository

$ sudo apt-get update
$ sudo apt-get install -y apt-transport-https curl lsb-core
$ echo "deb https://kong.bintray.com/kong-deb `lsb_release -sc` main" | sudo tee -a /etc/apt/sources.list
$ curl -o bintray.key https://bintray.com/user/downloadSubjectPublicKey?username=bintray
$ sudo apt-key add bintray.key
$ sudo apt-get update
$ sudo apt-get install -y kong

Choose database-backed or DB-less operation

Kong can run with a database or without one. In database-backed mode, kong.conf sets startup properties and the database stores configured entities such as Routes and Services. In DB-less mode, kong.conf and a kong.yml file define entities declaratively.

With a database

Kong supports PostgreSQL 9.5+ and Cassandra 3.x.x. For PostgreSQL, create the database and user before starting Kong:

CREATE USER kong;
CREATE DATABASE kong OWNER kong;

Then run the migrations:

$ kong migrations bootstrap [-c /path/to/kong.conf]

For Kong versions below 0.15 (up to 0.14), use the up subcommand instead of bootstrap. Those older releases also must not run migrations concurrently; only one Kong node should migrate at a time. The restriction is removed in Kong 0.15, 1.0, and later.

Without a database

Generate the declarative configuration first:

$ kong config init

This creates kong.yml in the current folder with instructions for filling it in. After editing it, set these options in kong.conf:

database = off
declarative_config = /path/to/kong.yml

Start and check Kong

$ kong start [-c /path/to/kong.conf]

Kong should now be running. Check the admin endpoint with:

$ curl -i http://localhost:8001/