Results 1 to 4 of 4

Thread: Rails 3.x /w Phusion Passenger in cPanel

  1. #1
    Registered User
    Join Date
    Dec 2005

    Default Rails 3.x /w Phusion Passenger in cPanel

    Thanks to Tristan Wallace @ cPanel for the instructions on getting Phusion Passenger to work properly!

    Installing mod_rails and Rails 3.0.9 on a cPanel machine | cPanel Blog

    NOTE: Rails functionality in cPanel will be BROKEN if you update Rails to 3.x. Rails 3.x is not officially supported in cPanel/WHM 11.34/11.36. This means you have to create rails apps manually and make direct edits to the Apache configuration using the distiller to save them. This will break clients' ability to add rails apps easily from their cPanel accounts. Only do this if a rails app absolutely requires Rails 3.x (e.g redmine 2.x). This will also break any existing Rails apps as cPanel uses a different framework (Mongrel) for Rails 2.x

    NOTE: git is required for this install. cPanel's official stance on git is to install it from source, as installing it from repositories requires that perl modules be installed from repositories as well, which is not supported in cPanel/WHM 11.34. See this link for instructions on installing git from source: Git - Installing Git

    First, install ruby and Ruby on Rails normally if they have not been already with:

    Once installed, force an install of the latest rails version with:

    gem install rails
    You will need to install the latest version of the passenger gem in order for it to work. Do the following:

    cd /usr/local/src
    git clone 
    cd passenger
    gem build passenger.gemspec
    gem install passenger-*.gem
    rm -rf /usr/local/src/passenger
    Make sure you note the version number, as that will be needed when configuring passenger in Apache.

    Now that passenger is properly installed, you can use it to compile the mod_passenger module for apache. Note that this action requires temporarily setting /tmp as executable

    mount -o remount,rw,exec,nosuid,loop=/dev/loop0 /usr/tmpDSK
    mount -o remount,rw,exec,nosuid /tmp
    mount -o remount,rw,exec,nosuid /var/tmp
    mount -o remount,rw,noexec,nosuid,loop=/dev/loop0 /usr/tmpDSK
    mount -o remount,rw,noexec,nosuid /tmp
    mount -o remount,rw,noexec,nosuid /var/tmp
    Now that the module is compiled into Apache, you can load it. Edit the Pre Main Global Include. You can do this in WHM under Service Configuration > Apache Configuration > Include Editor > Select Pre Main Global, or directly in SSH in the file /usr/local/apache/conf/includes/pre_main_global.conf. Append the following to the include:

    LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.0.rc4/libout/apache2/
    PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.0.rc4
    PassengerRuby /usr/bin/ruby
    Ensure that you are using the correct directory when loading the actual passenger module and the root for the gem

    Now, backup your main Apache config file and distill the changes using cPanel's Apache Distiller

    cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak-modrails
    /usr/local/cpanel/bin/apache_conf_distiller --update
    /etc/init.d/httpd restart
    If you get any errors, this is likely because your paths are incorrect for the LoadModule and PassengerRoot directives

    Rails 3.x /w mod_passenger is now installed. You can use the following to create a test rails application (replace username with a cPanel test account in your system)

    rails new /home/username/hello
    cd /home/username/hello
    rails generate scaffold person name:string password:string email:string age:integer
    rake db:create:all
    rake db:migrate
    ln -s /home/username/hello/public /home/username/public_html/hello
    cd /home/username/hello/db
    cp development.sqlite3 production.sqlite3
    chown -R username:username /home/username/hello
    echo "RailsBaseURI /hello" >> /home/username/hello/public/.htaccess
    /etc/init.d/httpd graceful
    The following will create the rails app, define the parameters, create a sqlite database, populate the database, setup the Rails URI, clone the development database to production, set permissions, and finally create the rails app in .htaccess.

  2. #2
    Registered User
    Join Date
    Dec 2005

    Default Re: Rails 3.x /w Phusion Passenger in cPanel

    I have also written a thread on setting up Redmine 2.x, a common rails application that requires Rails 3.x.

  3. #3
    Registered Member
    Join Date
    Feb 2008
    Atlanta, GA
    cPanel/WHM Access Level

    DataCenter Provider

    Default Re: Rails 3.x /w Phusion Passenger in cPanel

    FYI, since 11.36 git is already installed in WHM. You just have to use the full path to use it


  4. #4
    cPanel Staff
    Join Date
    Jan 2011
    Houston, TX

    Default Re: Rails 3.x /w Phusion Passenger in cPanel


    Please see the following post for full instructions for setting up a cPanel server with passenger rails:

    cPanel + Ruby on Rails + Phusion Passenger |

    Note that these instructions describe how to use custom directives inside a site's VirtualHost to override the DocumentRoot, so root access is required.


Similar Threads

  1. mod_rails (passenger) Instead of mongrel + Rails 3 support [Case 44197]
    By techmight in forum Feature Requests for cPanel & WHM
    Replies: 52
    Last Post: 10-14-2012, 06:41 PM
  2. Unicorn instead of or in addition to mod_rails/passenger/mongrel
    By yakatz9 in forum Feature Requests for cPanel & WHM
    Replies: 1
    Last Post: 11-08-2011, 12:38 PM
  3. Enterprise Ruby + Phusion Passanger
    By naquad in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 11-28-2010, 11:47 AM
  4. Passenger Phusion with Apache
    By joneslee85 in forum Feature Requests for cPanel & WHM
    Replies: 0
    Last Post: 10-04-2010, 09:01 AM
  5. Replies: 0
    Last Post: 05-12-2006, 04:00 PM