Up to $100 off Dedicated Servers

Using Passenger with cPanel on CentOS 7

Posted on by Helpful Humans of Liquid Web | Updated:
Reading Time: 3 minutes

Phusion Passenger is a web application server that can run Ruby, Node.js, and Python applications on your web server. It integrates with both Apache and Nginx to serve content to your visitors. Historically, this application was difficult to integrate with cPanel servers, which would combine the power of Ruby applications with the ease of management that cPanel provides, but recent advancements make setting up your Passenger module very simple on both a VPS server as well as a dedicated server. This easy walkthrough will show you how to add Passenger, Apache mod_passenger, and the supporting Ruby installation to cPanel.

Using Apache and Phusion Passenger to host Ruby sites on your cPanel server

For this installation, we’ll be using a CentOS 7 VPS with cPanel, and we are connected via SSH.

  1. First, we must make sure that we are using EasyApache 4, which was made available in WHM 58. If you aren’t running WHM 58 or greater, we recommend upgrading to the latest available ‘Release’ tier version to ensure you are getting the most out of your webserver.
  2. From the server’s command line as root, you can check for the existence of the blank file ‘/etc/cpanel/ea4/is_ea4’ to see if your system is running EasyApache 4. If the file isn’t there, you’ll need to upgrade from EasyApache 3.
    ls /etc/cpanel/ea4/is_ea4
  3. Once you are sure that your server is using EasyApache 4, the next step is to add the mod_passenger option into your EasyApache 4 configuration. From the command line, you can install the necessary module and its supporting packages using YUM. The command you would use is:
    yum -y update; yum -y install ea-ruby24-mod_passenger ea-ruby24-ruby-devel ea-apache24-devel
  4. There is one more item we need in order to install Ruby applications easily: bundle. Install it using ‘gem’:
    scl enable ea-ruby24 'gem install bundle'
  5. Let’s confirm that mod_passenger, the connector to Apache, was installed properly. From the command line, you would run this command:
    httpd -M | grep passenger
  6. Let’s also make sure that Passenger itself is set up and working. Run this command and press Enter to start the validator:
    scl enable ea-ruby24 'passenger-config validate-install'Output:
    What would you like to validate?
    Use <space> to select.
    If the menu doesn't display correctly, press '!' ‣ ⬢ Passenger itself
    ⬡ Apache------------------------------------------------------------------------- * Checking whether this Passenger install is in PATH... ✓
    * Checking whether there are no other Passenger installations... ✓

That’s all! Passenger is now installed on your cPanel server.

Example: Setting up a Ruby app with Phusion Passenger

Now that we have it set up, let’s configure a simple Ruby app.

  1. First, we must upload the software for our app into a folder on the cPanel account. This folder doesn’t have to be inside of public_html. In fact, it’s more secure if its outside of public_html. We’ll chose /home/username/rubyapp/ to upload our test files. Depending on how you manage your code, you might use FTP, SSH, or Git for this step.
  2. Next, we will need to install any gems that the Ruby app needs to work; its dependencies. This is done with the following command:
    gem install <gem_name>
    You can see the available gems using the following command:
    gem search
  3. Log into cPanel for the account for which you are setting up the Rails app, and go to the Application Manager (Home >> Software >> Application Manager). Click on ‘Register Application’. Add the details for your Ruby app here, including what domain and subfolder you wish to access the app from publicly, and the location of the installation. Usually this folder contains another folder called ‘app’, rubyapp/ in our example.Application Manager
  4. Save the configuration by selecting Deploy. This creates the appropriate Passenger configuration files and starts the application.

Once you save this application configuration, cPanel will add the necessary lines into your custom apache virtualhost include to proxy calls to the Passenger module. Give it a minute to restart apache, and then head to your website to see how you did!

systemctl restart httpd.service

Avatar for Helpful Humans of Liquid Web

About the Author: Helpful Humans of Liquid Web

Latest Articles

2024 cPanel and Plesk pricing breakdown

Read Article

CentOS Linux 7 EOL — everything you need to know

Read Article

How to install Node.js on Linux (AlmaLinux)

Read Article

Upgrading or installing PHP on Ubuntu — PHP 7.2 and Ubuntu 22.04

Read Article

Why is your IP blocked?

Read Article