Skip to content

Instantly share code, notes, and snippets.

@spkprav
Last active April 28, 2017 10:15
Show Gist options
  • Save spkprav/ed04066b8da186f17792389f247554e0 to your computer and use it in GitHub Desktop.
Save spkprav/ed04066b8da186f17792389f247554e0 to your computer and use it in GitHub Desktop.
Ubuntu, Rails, Puma and Nginx setup

Install dependecies:

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

RVM Installation:

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
rvm install 2.3.0
rvm use 2.3.0 --default
source ~/.rvm/scripts/rvm

Install Bundler:

sudo apt-get install bundler
gem install bundler

Install Nginx:

sudo apt-get install nginx

Install Postgresql:

sudo apt-get install postgresql postgresql-contrib libpq-dev

Install NodeJS:

sudo apt-get install nodejs

Disable Ruby Doc:

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

Edit PG_HBA

sudo nano /etc/postgresql/9.3/main/pg_hba.conf
Replace: "peer" to "trust"

Puma Upstart Setup:
https://github.com/puma/puma/tree/master/tools/jungle/upstart

ImageMagick Install:

sudo apt-get install imagemagick

Nginx Configuration:

upstream app {
  server unix:///{{project .sock file path}} fail_timeout=0;
}
server {
  listen 80;
  root {{project public folder path here}};
  location / {
    proxy_pass http://app;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
  }
  location ~ ^/assets/ {
    expires 1y;
    add_header Cache-Control public;
    add_header ETag "";
    break;
  }
  location ~* \.(csv|png)$ {
    root {{project public folder path here}};
  }
  error_page 500 502 503 504 /500.html;
  client_body_in_file_only clean;
  client_body_buffer_size 32K;
  client_max_body_size 300M;
  sendfile on;
  send_timeout 300s;
  keepalive_timeout 10;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment