This is a working document for me, hopefully I will eventually figure out how to run multiple puma apps on the same server. First of all, lets start fresh here.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD827BD9BF62Now add this to the bottom of /etc/apt/sources.list:
deb http://nginx.org/packages/ubuntu/ precise nginx
And install:
sudo apt-get purge nginx*
sudo apt-get update
sudo apt-get install nginx
nginx -v
sudo service nginx startStart by removing the default settings
sudo rm /etc/nginx/conf.d/sites-enabled/defaultYou may need to add this to your /etc/nginx/nginx.conf file:
include /etc/nginx/sites-enabled/*;This will include the default ubuntu structure, otherwise nginx will just look inside /etc/nginx/conf.d/*.
in /etc/nginx/sites-available/my_app.conf:
upstream my_app {
server unix:/home/deploy/my_app/shared/tmp/sockets/puma.sock;
}
server {
listen 80;
server_name my_app.com www.my_app.com; # what to listen for
root /home/deploy/my_app/public;
location / {
proxy_pass http://my_app; # links upstream
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
root /home/deploy/stringy/current/public;
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
}
}Then symlink and restart:
sudo ln -sf /etc/nginx/sites-available/my_app.conf /etc/nginx/sites-enabled/my_app.conf
sudo service nginx restartThis part gets really easy, simply navigate to the app and start up puma (start fresh):
ps ax | grep puma
pkill -f puma
bundle exec puma -e production -b unix:///var/run/my_app.sockIf everything boots up without errors, deamonize the process with -d.
Whammo! You're totally doing it bruh!