Skip to content

Instantly share code, notes, and snippets.

@anhldbk
Last active April 7, 2020 19:52
Show Gist options
  • Save anhldbk/6692e47735cb3480f6fc9f694da922c3 to your computer and use it in GitHub Desktop.
Save anhldbk/6692e47735cb3480f6fc9f694da922c3 to your computer and use it in GitHub Desktop.
Install Kong API Gateway on Ubuntu
sudo apt-get install netcat openssl libpcre3 dnsmasq procps perl
# for ubuntu 16.04 (xenial)
sudo apt-get -y install postgresql postgresql-contrib phppgadmin
sudo -i -u postgres
psql
CREATE USER kong; CREATE DATABASE kong OWNER kong;
ALTER USER kong WITH password 'kong';
# for ubuntu 16.04
https://github.com/Mashape/kong/releases/download/0.9.7/kong-0.9.7.xenial_all.deb
sudo dpkg -i kong-0.9.7.xenial_all.deb
sudo bash -c "echo -e 'pg_user = kong\npg_password = kong\npg_database = kong' > /etc/kong.conf"
kong start -vv
# autostart with upstart
sudo apt-get install upstart upstart-sysv
sudo update-initramfs -u
# remember the location of this script
bash -c "echo -e 'kong start -vv' > start.sh"
chmod +x start.sh
mkdir ~/.config
# Create /etc/init/kong.conf with following content
```sh
start on runlevel [2345]
stop on shutdown
script
bash $(pwd)/start.sh
end script
pre-start script
echo "[`date`] Starting Kong Server" >> /var/log/kong.log
end script
pre-stop script
echo "[`date`] Stopping Kong Server" >> /var/log/kong.log
end script
```
sudo apt-get install npm
sudo npm install -g n@latest
sudo n stable
# install kong dashboard
sudo npm install -g kong-dashboard
# Start Kong Dashboard
kong-dashboard start
# To start Kong Dashboard on a custom port
kong-dashboard start -p [port]
# To start Kong Dashboard with basic auth
kong-dashboard start -a user=password
@anhldbk
Copy link
Author

anhldbk commented Jan 15, 2017

Auto-start Checklist for Upstart

This section is a quick reference to make sure your service is set to automatically start.

Configuration Checklist
  • Make sure the service has a functional Upstart init script located at /etc/init/service.conf
  • The /etc/init/service.conf file should contain a line like start on runlevel [2345] to enable automatic starting after a reboot
  • The /etc/init/service.conf file should also contain a line like respawn to enable the service to respawn after a crash
  • Make sure there is no override file for the service: /etc/init/service.override

(There would be one only if you or another admin made one earlier)

Stop, then start, the service:

  sudo initctl stop service
  sudo initctl start service

Reboot the server.

  sudo reboot

@jeffersfp
Copy link

jeffersfp commented Jan 24, 2018

Thanks for the gist bro!

Setup of kong service via systemd is possible simply by creating a file at /lib/systemd/system/kong.service with the content:

[Unit]
Description= kong service
After=syslog.target network.target

[Service]
User=root
Group=root
Type=forking
ExecStart=/usr/local/bin/kong start
ExecReload=/usr/local/bin/kong reload
ExecStop=/usr/local/bin/kong stop

[Install]
WantedBy=multi-user.target

And then:

sudo systemctl daemon-reload
sudo systemctl start kong
sudo systemctl enable kong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment