Skip to content

Instantly share code, notes, and snippets.

@wilxsv
Last active March 13, 2018 05:31
Show Gist options
  • Save wilxsv/78e9c405ca3877dda58d5c8771a4f5b1 to your computer and use it in GitHub Desktop.
Save wilxsv/78e9c405ca3877dda58d5c8771a4f5b1 to your computer and use it in GitHub Desktop.
Install and config timeoverflow
# 1. Introduction
# TimeOveflow is specially designed for and by Time Banks that physically exist
# 2. Overview
# This tutorial assumes that you are using a Debian Jessie as operating system, in this installation we are using digital ocean VPS
# 3. Prerequisites
# As root install all packages
# Add jessie-backports
echo "deb http://ftp.debian.org/debian jessie-backports main contrib non-free" | sudo tee -a /etc/apt/sources.list.d/jessie-backports.list
echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger jessie main" | sudo tee -a /etc/apt/sources.list.d/passenger.list
apt-get update
# Install dependencies
apt-get install -y wget apt-transport-https postgresql postgresql-contrib libpq-dev git libreadline-dev autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
# Install elasticsearch
apt-get -t jessie-backports install elasticsearch
# 3. Configuring Dependencies
# 3.1 Configure elasticsearch
# Edit file elasticsearch.yml as example, see the file elasticsearch.yml
nano /etc/elasticsearch/elasticsearch.yml
# Edit file elasticsearch.yml as example, see the file elasticsearch.yml
nano /etc/default/elasticsearch
systemctl restart elasticsearch.service
# Or /etc/init.d/elasticsearch restart
# Verify that elasticsearch is working
curl -X GET http://127.0.0.1:9200
# The output is:
#{
# "status" : 200,
# "name" : "Xemnu the Titan",
# "cluster_name" : "elasticsearch",
# "version" : {
# "number" : "1.6.2",
# "build_hash" : "NA",
# "build_timestamp" : "NA",
# "build_snapshot" : false,
# "lucene_version" : "4.10.4"
# },
# "tagline" : "You Know, for Search"
#}
# 3.2 add user
# Install using username dev with sudo actived in debian 8
# Create user if not exist
adduser dev
# add to sudo group
nano /etc/sudoers
/etc/init.d/sudoers restart
# 3.3 Installing ruby enviroment
su dev
# In this point we are dev user
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install 2.3.0
rbenv global 2.3.0
echo "gem: --no-document" > ~/.gemrc
gem install bundler
gem env home
gem install rails
# 3.4 Installing node.js
cd /tmp
\curl -sSL https://deb.nodesource.com/setup_6.x -o nodejs.sh
cat /tmp/nodejs.sh | sudo -E bash -
sudo apt-get install -y nodejs
# 3.5 Creation postgres user for timeoverflow and set password
sudo -u postgres createuser --interactive
# In psql type "alter user USER password 'PASSWD';"
# 4. timeOverFlow installation and configuration
# 4.1. Installation
# In this point we are dev user, and we are in home path /home/dev/
git clone https://github.com/coopdevs/timeoverflow.git
cd timeoverflow/
bundle install --path vendor/bundle
# 4.2. SET environment vars
# Edit file .env.example and save as .env
# See file env
# 4.X. Verification
rails s -b 0.0.0.0
# 5. Production installation with Nginx (enabled HTTPS)
# 5.1 Install passenger
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
apt-get install -y nginx-extras passenger
# Uncomment it if you installed passenger or passenger-enterprise in /etc/nginx.conf
# include /etc/nginx/passenger.conf;
# 5.2 Verify passenger configuration
sudo /usr/bin/passenger-config validate-install
# 5.3 Configure certificates
# 5.4 Configure vhost
# See file site-nginx-https.conf
# 5.5 Enable vhost
# 6. Troubleshooting
# 6.X Logs
# 6.X Logs
# 6.X Logs
# 6.X Logs
# 6.X Logs
tailf
Lynks
https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html
https://github.com/coopdevs/timeoverflow/wiki/Build-development-environment-with-LXC-for-GNU-Linux
##################### Elasticsearch Configuration Example #####################
# SET this configuration,
############################## Network And HTTP ###############################
network.bind_host: localhost
network.publish_host: localhost
network.host: localhost
#transport.tcp.port: 9300
http.port: 9200
# database setup:
DATABASE_ADAPTER=postgres
DATABASE_USER=timeoverflowpostgres
DATABASE_PASSWORD=PASSWD
DATABASE_HOST=127.0.0.1
# host part of the url for mail links:
MAIL_LINK_HOST=localhost:3000
# a list of emails for superadmin users
ADMINS="[email protected]"
# database setup:
#DATABASE_NAME=timeoverflow_development
#DATABASE_NAME=timeoverflow_test
#DATABASE_NAME=timeoverflow_staging
DATABASE_NAME=timeoverflow
DATABASE_URL=postgres://timeoverflowpostgres:[email protected]:5432/timeoverflowdatabase
# SET this configuration, uncoment
START_DAEMON=true
ES_USER=elasticsearch
ES_GROUP=elasticsearch
LOG_DIR=/var/log/elasticsearch
DATA_DIR=/var/lib/elasticsearch
WORK_DIR=/tmp/elasticsearch
CONF_DIR=/etc/elasticsearch
CONF_FILE=/etc/elasticsearch/elasticsearch.yml
RESTART_ON_UPGRADE=true
server {
listen 80;
server_name bdtc.wvides.info www.bdtc.wvides.info;
location / {
return 301 https://bdtc.wvides.info$request_uri;
}
}
server {
listen 443 ssl;
server_name bdtc.wvides.info;
# This is a certificates generated by letsencrypt
ssl_certificate /etc/letsencrypt/live/bdtc.wvides.info/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/bdtc.wvides.info/privkey.pem;
include snippets/ssl-params-last.conf;
root /home/dev/timeoverflow/public;
passenger_enabled on;
passenger_ruby /home/dev/.rbenv/versions/2.3.0/bin/ruby;
error_log /var/log/nginx/timeoverflow-error.log;
access_log /var/log/nginx/timeoverflow-access.log;
}
deb http://mirrors.digitalocean.com/debian jessie main contrib non-free
deb-src http://mirrors.digitalocean.com/debian jessie main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free
# jessie-updates, previously known as 'volatile'
deb http://mirrors.digitalocean.com/debian jessie-updates main contrib non-free
deb-src http://mirrors.digitalocean.com/debian jessie-updates main contrib non-free
# jessie-backports
deb http://ftp.debian.org/debian jessie-backports main contrib non-free
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment