• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Deploy Ruby App with Nginx and Passenger on CentOS 7/6, Fedora 27/26

Written by Rahul, Updated on October 31, 2017

Phusion Passenger is an application server which can be integrated into web server like Apache and Nginx web servers and allows to serve Ruby/Rails applications via the web server. It’s a good option to deploy Ruby on Rails application on productions systems. This article will help you to deploy Ruby on Rails application with Nginx on Linux systems like CentOS 7/6 and Fedora 27/26. You can use this tutorial for staging as well as production deployments.

First of all, we assume you already have Ruby installed on your system. If you do not have Ruby installed, use below URL to install it as per your application requirements.

  • Install Ruby on CentOS, RedHat, Fedora

Step 1 – Install Prerequisites

First of all, enable epel yum repository and update packages on your system.

$ sudo yum install -y epel-release yum-utils
$ sudo yum-config-manager --enable epel
$ sudo yum clean all && sudo yum update -y

Step 2 – Install Nginx Passenger Module

Now install rails and passenger gem on your system. Execute below commands to install both gem command.

$ sudo yum install -y pygpgme curl

$ sudo curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo

Now install the passenger on your system using the following command. Also, install or update Nginx on your system.

$ sudo yum-config-manager --enable cr && sudo yum install -y nginx passenger

Step 3 – Enable Nginx Passenger Module

At this time you have installed Passenger and Apache server on your system. Now execute below command to install the passenger module for Apache. This command will show you the guided installation and tell you for any missing dependencies to install.

$ vim /etc/nginx/conf.d/passenger.conf
passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/local/rvm/rubies/ruby-2.4.2/bin/ruby;
passenger_instance_registry_dir /var/run/passenger-instreg;

The default passenger_ruby will be set up for the /usr/bin/ruby. I have changed the binary path to our custom installed Ruby version using RVM.

Step 4 – Configure Nginx VirtualHost

Let’s configure the VirtualHost in Nginx configuration file with the domain name. The example virtual host configuration will look like below.

   server {
        listen       80 default_server;
        server_name  example.com www.example.com;
        root         /var/www/html/public;
        passenger_enabled on;

   }

Step 5 – Restart Nginx Service

After adding above lines in Apache configuration, restart Apache service using the following command.

$ sudo systemctl restart nginx.service

Congratulation! you have configured Ruby on Rails Application with Nginx.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

1 Comment

  1. Avatar Daniel Wong Reply
    May 24, 2019 at 3:59 am

    Hi, my app was working for quite some time until recently, it gave me a 500 error with:

    Cannot stat ‘/home/profile/public_html/current/passenger_wsgi.py’: Permission denied (errno=13);

    Any ideas of what could be causing it?

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy