Install Kong and Konga on CentOS7
1. Install Kong
Install environment
# yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel git
![](https://blog.unixdev.co.th/content/images/2021/08/image-10.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-11.png)
Install postgresql 10
# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# yum install -y postgresql10-server
# yum install -y postgresql10-server
# /usr/pgsql-10/bin/postgresql-10-setup initdb
# systemctl enable postgresql-10
# systemctl start postgresql-10
![](https://blog.unixdev.co.th/content/images/2021/08/image-12.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-13.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-14.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-15.png)
Change password postgres and add user kong
# passwd postgres
# adduser kong
# passwd kong
![](https://blog.unixdev.co.th/content/images/2021/08/image-16.png)
Create DB for Kong
# su postgres
psql
create user kong with password 'your_password';
create database kong owner kong;
grant all privileges on database kong to kong;
\q
exit;
![](https://blog.unixdev.co.th/content/images/2021/08/image-17.png)
Config Postgres
# vim /var/lib/pgsql/10/data/pg_hba.conf
![](https://blog.unixdev.co.th/content/images/2021/08/image-55.png)
add this
host all all 127.0.0.1/32 trust
![](https://blog.unixdev.co.th/content/images/2021/08/image-50.png)
# vim /var/lib/pgsql/10/data/postgresql.conf
listen_addresses = 'localhost'
![](https://blog.unixdev.co.th/content/images/2021/08/image-51.png)
# systemctl restart postgresql-10.service
Install Kong
You Can install from this web
![](https://docs.konghq.com/assets/images/share.png)
# cp /etc/kong/kong.conf.default /etc/kong/kong.conf
# vim /etc/kong/kong.conf
admin_listen =0.0.0.0:8001
database = postgres
pg_host = 127.0.0.1
pg_port 5432
pg_user = kong
pg_password = your_password #PASSWORD POSTGRESQL USER KONG
pg_database = kong
![](https://blog.unixdev.co.th/content/images/2021/08/image-20.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-22.png)
Start kong
# kong migrations bootstrap -c/etc/kong/kong.conf
# kong start -c/etc/kong/kong.conf --vv
# curl 127.0.0.1:8001
![](https://blog.unixdev.co.th/content/images/2021/08/image-24.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-25.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-26.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-27.png)
2. Install Konga
Check firewall allow 1337
Install environment (don't use root for install )
# su kong
$ cd
(Recommend install nodejs ver. 12.16.x)
install nvm
$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
$ source ~/.bashrc
$ nvm install 12.16
![](https://blog.unixdev.co.th/content/images/2021/08/image-28.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-30.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-33.png)
$ npm install npm@latest -g
![](https://blog.unixdev.co.th/content/images/2021/08/image-34.png)
$ npm install -g gulp bower sails
![](https://blog.unixdev.co.th/content/images/2021/08/image-35.png)
Download and install Konga
$ git clone https://github.com/pantsel/konga.git
$ cd konga
$ npm i
![](https://blog.unixdev.co.th/content/images/2021/08/image-36.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-37.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-38.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-39.png)
Add database for konga
$ su postgres
psql
CREATE USER konga WITH PASSWORD'your_password';
CREATE DATABASE konga OWNER konga;
grant all privileges on database konga to konga;
\q
exit;
![](https://blog.unixdev.co.th/content/images/2021/08/image-40.png)
Test connect database
$ node ./bin/konga.js prepare --adapter postgres --uri
postgresql://konga:your_password@127.0.0.1:5432/konga
![](https://blog.unixdev.co.th/content/images/2021/08/image-41.png)
Copy the configuration file template as .env
$ cp -r .env_example .env
$ vim .env
HOST=your_ip
PORT=1337
NODE_ENV=production
KONGA_HOOK_TIMEOUT=120000
DB_ADAPTER=postgres
#DB_URI=postgresql://localhost:5432/konga
DB_USER=konga
DB_PASSWORD=your_password
DB_PORT=5432
DB_DATABASE=konga
KONGA_LOG_LEVEL=warn
TOKEN_SECRET=some_secret_token
![](https://blog.unixdev.co.th/content/images/2021/08/image-42.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-43.png)
Start Konga
$ npm run production &
(& mean Background start)
![](https://blog.unixdev.co.th/content/images/2021/08/image-44.png)
Konga use port 1337
![](https://blog.unixdev.co.th/content/images/2021/08/image-52.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-47.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-48.png)
![](https://blog.unixdev.co.th/content/images/2021/08/image-49.png)
Stop Konga
$ ps -aux | grep node
![](https://blog.unixdev.co.th/content/images/2021/08/image-56.png)
$ kill -9 30936