Call Us! 1-800-383-5193
Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Emergency Response Time custom

Our experts have had an average response time of 11.06 minutes in March 2021 to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

Using Phusion Passenger (a.k.a mod_rails) On cPanel Server

by | Aug 13, 2008

Phusion Passenger (mod_rails or mod_rack ) makes execution of Ruby web applications more easier on Apache webserver. It requires no maintenance from our part and minimal port management. It was designed keeping in mind performance, stability and security.

Here I am explaining more about deploying this module on Linux servers using cPanel as the control panel.

Currently in cPanel, by default, the Ruby On Rails(RoR) applications are using Mongrel webserver. By Phusion Passenger, we can use Apache itself for RoR applications, instead of redirecting the application to Mongrel.


We can install Phusion Passenger using different methods. An Easy way is to use gem to install Phusion Passenger in two simple steps. Make sure that RoR is already installed on your cPanel server using ‘/scripts/installruby‘.

Step 1: #gem install passenger
Step 2: #passenger-install-apache2-module

In the second step, while installing ‘passenger-install-apache2-module’, I ran into two errors. The errors and corresponding solutions are given below.

Error 1: Apache 2 development headers were not detected by the script.

Checking for required software...

 * GNU C++ compiler... found at /usr/bin/g++
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/bin/rake
 * Apache 2... found at /usr/local/apache/bin/httpd
 * Apache 2 development headers... missing..(some error here)

Solution: Here the script is checking for apxs installation path. On a cPanel server, the default path is ‘/usr/local/apache/bin/apxs‘. But the script was looking for ‘/usr/sbin/apxs’. To solve this, I created a symbolic link from ‘/usr/sbin/apxs‘ to ‘/usr/local/apache/bin/apxs‘.

Error 2: Another error that came up was:

/usr/local/apache/include/apr_file_info.h:200: error: 'apr_ino_t' does not name a type ..."

Solution: There were two installation of apr on the server. One by default and one by cPanel. The passenger script was taking binary path from one installation and include files from other. I moved the default installation on the server to a backup folder and created a symbolic link from default installation’s include directory to apr include directory of cPanel. The command for this is given below:

#ln -s /usr/local/apache/include/ /usr/include/apr-1

Loading Modules

After completing the ‘passenger-install-apache2-module’ step successfully, add the corresponding Modules to Apache configuration file.

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-
   PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.2
   PassengerRuby /usr/bin/ruby

Save and restart Apache.

#/usr/local/cpanel/bin/apache_conf_distiller --update
#/etc/init.d/httpd restart.

Deploying RoR application:

Suppose, we have a RoR application in “/home/username/testapp”. Follow the steps given below to redirect the main domain to this application.

Step 1: By default the Document root of this domain will be /home/username/public_html/. Create a symbolic link from /home/username/public_html/ to the RoR application’s public directory, /home/username/testapp/public/.

-bash-3.2# ln -s  /home/username/testapp/public/ /home/username/public_html

Step 2: Then add the following rule in the virtual host entry of the domain.

RailsBaseURI /

Note : If you want to redirect a subdirectory under public_html like http://domainname/rails to the RoR’s application, change the symbolic link accordingly and specify the rule in the domain’s virtualhost entry as:

RailsBaseURI /subdirectory_name

It is not recommended to edit the virtual host entry directly. You can add this rule in the include file mentioned in the virtual host entry of the domain.

Include "/usr/local/apache/conf/userdata/std/2/username/domain_name/*.conf"

By default these include files will be commented in the configuration file. We have to manually create directories corresponding to this include file.

Directories up-to /usr/local/apache/conf/ were already there in the server. I created new sub-directories from ‘userdata’ to ‘domain_name’. Under the directory /usr/local/apache/conf/userdata/std/2/username/domain_name/, you can create any file with .conf extension. I created the file rails.conf to add the “RailsBaseURI” rule.

-bash-3.2# ll /usr/local/apache/conf/userdata/std/2/username/domain_name/
total 4
-rw-r--r-- 1 root root 15 Jul 31 04:05 rails.conf

Step 3: After that, execute the below command,

#/scripts/ensure_vhost_includes --user=username  (Use cpanel username of that domain)

Step 4: You can restart the RoR application by restarting Apache or using the command,

#touch /path_to_application/tmp/restart.txt

In this case,

#touch /home//username/testapp/tmp/restart.txt

The domain will now work fine using this new mod_rails installation. 🙂 Make sure that you are not starting or restarting this application from cPanel >> Ruby On Rails option. It will switch to Mongrel webserver.

You can check Apache error log file itself for errors.


Although cPanel is not using this module (mod_rails) with Easyapache script and in their Ruby Ob Rails interface. By following this method, we can use this module on a cPanel server with much ease.

Phusion Passenger conflicts with some Apache modules like mod_rewrite and mod_alias. They may be installed together with mod_passenger and used outside virtual hosts that contain a Rails application. Phusion Passenger recommend not to use their features inside virtual hosts that contain a Rails application. Rewrite rules are mainly used to accelerate caching of pages. Phusion Passenger supports page caching without mod_rewrite. So there is no need to worry about this.

Reference :

Articles by Anusha M.K

About the author
Anusha M.K has been working with Bobcares for more than one and half years. She specializes on Linux and Windows server administration using variety of control panels. She is an expert in Ruby On Rails technology especially its configurations and deployment in Linux servers.



  1. Firstly make sure you add the generated code to :


    and not


    or otherwise cPanel will overwrite it when it does updates.

    Another way or running the command to install the passenger Apache2 Module without creating a link is :

    APXS2=/usr/local/apache/bin/apxs PATH=$PATH:/usr/local/apache/bin passenger-install-apache2-module

  2. Hi

    I get the following error after the script successfully ran:

    /usr/local/bin/rails /usr/local/bin/ruby : bad interpreter: No such file or directory

  3. Hi,

    If you are executing the application using any scripts in the scripts directory of rails application, make sure that rails/ruby is installed in the interpreter path defined in that file. You can see the shebang line as,

    #!/usr/bin/env ruby

    In this case, ruby should be installed in /usr/bin/ruby. Like this, check your ruby installation path.

  4. In my case, I didn’t get any error in the first part “Checking for required software…” but I get this error in the second part “Compiling and installing Apache 2 module…”:

    g++ ext/common/ApplicationPoolServerExecutable.cpp -o ext/apache2/ApplicationPoolServerExecutable -Iext -Iext/common -fPIC -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -I/usr/local/apache/include -I/usr/local/apache/include -I/usr/local/apache/include -D_REENTRANT -I/usr/local/include -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS ext/apache2/libpassenger_common.a ext/apache2/libboost_oxt.a -fPIC -L/usr/local/apache/lib -lapr-0 -L/usr/local/apache/lib -laprutil-0 -lpthread
    /usr/local/apache/lib/ undefined reference to `XML_ParserCreate’
    /usr/local/apache/lib/ undefined reference to `XML_GetErrorCode’
    /usr/local/apache/lib/ undefined reference to `XML_SetUserData’
    /usr/local/apache/lib/ undefined reference to `XML_ErrorString’
    /usr/local/apache/lib/ undefined reference to `XML_ParserFree’
    /usr/local/apache/lib/ undefined reference to `XML_SetElementHandler’
    /usr/local/apache/lib/ undefined reference to `XML_Parse’
    /usr/local/apache/lib/ undefined reference to `XML_SetCharacterDataHandler’
    collect2: ld returned 1 exit status
    rake aborted!
    Command failed with status (1): [g++ ext/common/ApplicationPoolServerExecut…]
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.1/Rakefile:211:in `define_common_library_task’
    (See full trace by running task with –trace)

    Any ideas?

  5. gdelfino: I’m getting the same. I’ll try to update if I get past it.

Privacy Preference Center


Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]


Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid


Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie


These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.