Install Server Run Rails App On Production Using Puma + Nginx

Tram Ho

Original article on my blog: Server Running Rails App On Production Using Puma + Nginx

Puma is a compact web server built into Rails that helps developers start coding as quickly as possible. However, making it a real web server to run on production environments is not ok. In this article, I want the memo to share with you the steps to install the server so that the Rails application runs smoothly on the production environment.


  • OS environment is Amazon linux
  • Database used is Postgres

System configuration

Puma acts as an application server for the Rails application, and Nginx will act as a reverse proxy – receiving requests and passing responses between the client and Puma. Puma and Nginx communicate with each other via sockets.

  • rbenv + Ruby 2.5
  • Rails 5 + Puma + Nginx


Source Image:

Ok, ssh on the server and start the installation! ↓↓↓

1. Prepare the environment

2. Create a user

A good habit is not to use the default user / ec2-user, so we will create a new user to serve the installation and launch of the Rails application.

3. Install rbenv and Ruby

Use rbenv to manage versions of ruby.

4. Prepare for the Rails application

5. Install Puma as a service – run in the background and start automatically

Reference puma.service file

6. Install Nginx

File greatapp.nginx.conf for reference

7. Setting log rotation

Logs of nginx, puma, rails will increase over time, so setting the rotation log is a habit we should do.

File greatapp.logrotate.conf for reference

Share the news now

Source : Viblo