Skip to content

Instantly share code, notes, and snippets.

@yosukehasumi
Created November 28, 2017 18:32
Show Gist options
  • Save yosukehasumi/5a938c3478c212dc962cc4f1eec0e624 to your computer and use it in GitHub Desktop.
Save yosukehasumi/5a938c3478c212dc962cc4f1eec0e624 to your computer and use it in GitHub Desktop.
Setting up Propeller One Digital Ocean droplet

Install Postgres

http://technobytz.com/install-postgresql-9-3-ubuntu.html

sudo apt-get update
sudo apt-get -y install python-software-properties
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Get the codename from:

lsb_release -c

And paste it into here

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ CODENAME-pgdg main" > /etc/apt/sources.list.d/postgresql.list'
sudo apt-get update
sudo apt-get install postgresql-9.3 pgadmin3

Create Postgresql user

sudo -u postgres psql

Install NGINX

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-14-04-lts

sudo apt-get update
sudo apt-get install nginx

Create SSH user

adduser propellerone
usermod -aG sudo propellerone
su - propellerone
ssh-keygen

RBENV

https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04

sudo apt-get update

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

Now switch to a user that will be using ruby su - propellerone

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

Again as the user the will be using ruby

rbenv install -v 2.2.6
rbenv global 2.2.6

Check it

ruby -v

Skip the docs for all your gem installs

echo "gem: --no-document" > ~/.gemrc

get the bundler

gem install bundler

get rails

gem install rails

Rehash after installing a new ruby

rbenv rehash

Install Javascript Runtime (Node)

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

Create SWAP file

Create

sudo fallocate -l 4G /swapfile

Verify

ls -lh /swapfile

Lock it

sudo chmod 600 /swapfile

Make it SWAP

sudo mkswap /swapfile

Enable it

sudo swapon /swapfile

Verify

sudo swapon --show

Make it permanent

sudo cp /etc/fstab /etc/fstab.bak;
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Let's Encrypt

Install Certbot

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx

Edit NGINX

sudo nano /etc/nginx/sites-available/default

Inside the server block, add this location block

  location ~ /.well-known {
    allow all;
  }

Check your NGINX config file

sudo nginx -t

Restart NGINX

/etc/init.d/nginx restart

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04

Get your cert (make sure you know your webroot)

sudo certbot --nginx -d propone.mediumraredev.com

Install Passenger

sudo apt-get install -y dirmngr gnupg
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
sudo apt-get install -y nginx-extras passenger

uncomment passenger config in /etc/nginx/nginx.conf

include /etc/nginx/passenger.conf;

Modify /etc/nginx/sites-enabled/default

passenger_enabled on;
rails_env    staging;
root /var/www/propellerone/current/public;
passenger_app_root /var/www/propellerone/current;

Restart

sudo /etc/init.d/nginx restart
passenger-config restart-app

Cap

Add to the bottom of /etc/sudoers

propellerone ALL=(ALL) NOPASSWD: ALL

Copy

config/provision/roles/app/templates/upstart-propellerone-sidekiq.conf
config/provision/roles/app/templates/upstart-propellerone-workers.conf

to

/etc/init/upstart-propellerone-sidekiq.conf
/etc/init/upstart-propellerone-workers.conf

Redis

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-redis

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install tcl8.5 
wget http://download.redis.io/releases/redis-stable.tar.gz
tar xzf redis-stable.tar.gz
cd redis-stable
make
make test
sudo make install

Nginx

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