Latest Ruby on Debian 8 with multi-site

Short notes, how to configure Ruby on Debian 8 and store Slate (helps you create beautiful, intelligent, responsive API documentation)

Preinstall pkgs
apt-get update
apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev git

Configure Ruby
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
type rbenv
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install -l
rbenv install 2.3.3
rbenv global 2.3.3
ruby -v
echo "gem: --no-document" > ~/.gemrc
gem install bundler
gem install middleman

Startup service
[Unit]
Description=Middleman client-api container

[Service]
User=www-data
Restart=always
WorkingDirectory=/var/www
ExecStart=/bin/bash -lc 'source /var/www/.bashrc ; cd /var/www/api/current ; bundle exec middleman server --port=4572 --watcher-force-polling --watcher-latency=1'

[Install]
WantedBy=default.target

Nginx config
server {
  listen 443 ssl;
  root /var/www/;
...
  location = /api {
    return 302 /api/;
  }
  location ~ ^/api(/?)(.*)$ {
    proxy_pass http://127.0.0.1:4572/$2$is_args$args;
  }
...
}

Comments

Popular posts from this blog