Let’s suppose we have VPS server with ubuntu installed, we have developed a rails application that is ready to be deployed.
We want to run the app in production mode.
At the end of this tutorial we will have the app that uses puma and revealed to the world via nginx.
Make sure you have installed following packages on VPS:
Open Gemfile and add following gems:
Generate capistrano files:
Uncomment and add these lines in Capfile:
Now trarget capistrano to your VPS server with editing of config\deploy\production.rb:
Nice. Now we need to edit config\deploy.rb file. Please add these lines:
Ok, let’s try to deploy the app:
You have to get errors. Let me explain a schema we’re going to use.
Normally if you use Rails 5 it uses puma as default server. When you start an app with rails s command puma reads config\puma.rb configuration file and gets started.
Since we’re going to use puma on VPS things could be a bit different and we need different configuration file.
Thus in order to not mess with default configuration file we will use puma.conf. This file will be used only on VPS.
Log in on you VPS and create ~/projects/my_app/shared/puma.conf and copy this:
Try again. You should get something alike below:
You can control your puma server with commands:
Now we need to care about that our app is get started on system boot. For this we use jungle.
Do not use cap production puma:jungle:install instead log in on VPS server. Download two bash scripts: