Skip to content

Instantly share code, notes, and snippets.

@AKNiazi
Last active September 2, 2016 17:18
Show Gist options
  • Save AKNiazi/d366ccd16e86ec47224c to your computer and use it in GitHub Desktop.
Save AKNiazi/d366ccd16e86ec47224c to your computer and use it in GitHub Desktop.
Manual Deployment with nginx and puma
Link I used i the following steps is https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04 and this link http://ruby-journal.com/how-to-setup-rails-app-with-puma-and-nginx/
Also a useful link to do this properly is http://nicolas-brousse.github.io/ubuntu-install-and-tips/pages/installation/rails-puma/
1. Install DBMS (postgre, mysql) and install rvm, ruby, rails and there dependencies
2. clone the git repository to any location ideally in home
3. cd myapp
4. bundle install
4. RAILS_ENV=production rake db:create
5. RAILS_ENV=production rake db:migrate
6. RAILS_ENV=production rake assets:precompile
7. Make sure you have gem puma in the Gem file then
8. cd ~
wget https://raw.githubusercontent.com/puma/puma/master/tools/jungle/upstart/puma-manager.conf
wget https://raw.githubusercontent.com/puma/puma/master/tools/jungle/upstart/puma.conf
9. vi puma.conf
In the puma.conf file look for
setuid deploy
setgid deploy where deploy is the user of the linux you can using to deploy
10. sudo cp puma.conf puma-manager.conf /etc/init
11. sudo vi /etc/puma.conf (in the file add the complete path to the app)
12. Start the puma manager sudo start puma-manager
13. Install nginx
14. sudo vi /etc/nginx/sites-available/default
15. Copy this text
upstream app {
# Path to Puma SOCK file, as defined previously
server unix:///tmp/my_app.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
root /home/deploy/appname/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
then
16 restart the server sudo service nginx restart
17. Start puma server
bundle exec puma -e production -d -b unix:///tmp/my_app.sock
18. ps aux | grep puma
19. To kill puma server
20. kill -s SIGTERM 9594
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment