Skip to content

How to Deploy Kails

Embbnux Ji edited this page Feb 17, 2017 · 5 revisions

install on ubuntu

install nodejs

sudo apt-get install -y build-essential
sudo apt-get install openssl
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

install redis

sudo apt-get install redis-server

install postgres

sudo apt-get install postgresql-client
sudo apt-get install postgresql
sudo su - postgres
psql
CREATE USER kails WITH PASSWORD 'password123';
CREATE DATABASE kailsdb OWNER kails;
GRANT ALL PRIVILEGES ON DATABASE kailsdb to kails;
\q
exit

set ENV variable

add below to ~/.bashrc

export PORT=5000
export HOST_NAME_PRO=https://kails.org
export ASSET_HOST_PRO=https://kails.org
export REDIS_URL_PRO=redis://localhost:6379/1
export DATABASE_USERNAME_PRO=kails
export DATABASE_PASSWORD_PRO=password123
export DATABASE_NAME_PRO=kailsdb
export DATABASE_HOST_PRO=localhost
export SECRET_KEY_BASE=d1212131d121213109789bcfbe4b337efc311bcfae4be42a311bc132498268c33551112234f464d3ada11bcfce4b431abcfae4b6486bce777caa962d75a18d1212131
source ~/.bash

start kails

to clone kails from github

mkdir -p /opt/www/
cd /opt/www/
git clone https://github.com/embbnux/kails.git
cd kails
npm i
# compile assets
npm run assets_compile
npm run build
# start app
npm run pm2
# restart app
npm run pm2:restart

Now kails will be available on 127.0.0.1:5000

nginx

sudo apt-get install nginx

cat /etc/nginx/sites-enabled/kails.conf :

upstream kails {
  server 127.0.0.1:5000;
}
server {
  listen 80;
  server_name kails.org;
  root /opt/www/kails/public;
  location / {
    index  index.html index.htm;
    proxy_pass http://kails;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
  location ~* ^/assets/ {
    root /opt/www/kails/public;
    expires 1y;
    add_header Cache-Control public;

    add_header Last-Modified "";
    add_header ETag "";
    break;
  }
}

restart nginx

sudo service nginx restart

install with docker

How to Deploy Kails with docker