• 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 Apache and Passenger on Ubuntu and Debian

Written by Rahul, Updated on October 31, 2017
General Articles mod passenger, passenger, rails, ruby

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 app with Apache on Linux systems like Ubuntu and Debian systems. 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 on your system, Use one of below URL to install it as per your application requirements.

  • How to Install Latest Ruby on Debian, Ubuntu, Linuxmint

Step 1 – Prerequisites

First of all, enable the HTTPS support for Apt repositories and install the PGP keys for passenger packages on your system.

$ sudo apt-get install -y dirmngr gnupg
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
$ sudo apt-get install -y apt-transport-https ca-certificates

Then, add the passenger repository reference to below file. The `lsb_release -cs` will set the codename of your operating system. You can also change this and set the codename manually.

$ sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger `lsb_release -cs` main > /etc/apt/sources.list.d/passenger.list'

Step 2 – Install Passenger Apache module

Now install the Apache passenger module on your system. You can also specify to install or upgrade Apache2 to the latest version.

$ sudo apt-get install -y apache2 libapache2-mod-passenger

Now enable the passenger module (if not enabled already) using the following command. After that restart Apache service to reload the new settings.

$ sudo a2enmod passenger
$ sudo systemctl restart apache2.service

Step 3 – Create Apache VirtualHost

Now, you can deploy your Ruby/Rails application on this server. Create a Apache configuration file and configure the virtual host like blow.

$ vim /etc/apache2/sites-available/example.com.conf

Change the document root as per your application location on disk.

<VirtualHost *:80>
    ServerName example.com

    ### Path to Ruby Application's 'public' directory ### 
    DocumentRoot /path-to-your-app/public

    <Directory /path-to-your-app/public>
	  Allow from all
	  Options -MultiViews
	  ### Uncomment this if you're on Apache > 2.4: ### 
	  # Require all granted
    
    </Directory>
</VirtualHost>

Now, enable the newly created Apache site configuration file.

$ sudo a2ensite example.com

Step 4 – Verify Setting and Restart Apache

Execute the below command to validate the passenger installation on your system.

$ sudo /usr/bin/passenger-config validate-install

All checks should be passed properly. If any of check failed, it will help you to fix.

Deploy Ruby App

$ sudo systemctl restart apache2.service

Share it!
Share on Facebook
Share on Twitter
Share on Google+
Share on Reddit
Share on Tumblr
Rahul
Rahul
Connect on Facebook Connect on Twitter Connect on Google+

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..

Related Posts

  • How to Deploy Ruby App with Nginx and Passenger on Ubuntu and Debian

    October 26, 2017
  • How to Deploy Ruby Application with Passenger and Apache on CentOS 7/6, Fedora 27

    October 17, 2017
  • How to Install Ruby on CentOS/RHEL 7/6

    February 3, 2017
  • How to Install Ruby on Fedora 29-25 with RVM

    February 1, 2017
  • How to Install Ruby 2.2.4 on CentOS/RHEL with RVM

    December 17, 2015

Leave a Reply

Cancel reply

Popular Posts

  • How to Setup Squid Proxy Server on Ubuntu 18.04 & 16.04
  • How To Install Zabbix Agent on Debian 9/8
  • How to Install and Configure Squid Proxy on Debian 9
  • How to Remove “public/index.php” from URL in Laravel
  • How To Install Wine 3 on Debian 9 (Stretch)
All rights reserved. © 2013-2018 TecAdmin.net. This site uses cookies. By using this website you agree our term and services