cPanel has built-in support for Rails apps using Mongrel but this involves multiple servers and port forwarding and only allows one applicaiton per cPanel user. Phusion Passenger is an Apache (and Nginx) module that allows Rails applications to be run directly through the web server without further configuration. Normal installation of Phusion Passenger is very straight-forward but on cPanel servers, it must be installed in a cPanel-friendly way.
All of the following commands need to be run as root or with the use of sudo:
First, make sure Ruby is installed:
root@host:[~]$ /scripts/installruby
Next, install Passenger:
root@host:[~]$ gem install passenger
Then set the paths to Apache and the Apache dev headers and run the installer:
root@host:[~]$ APXS2=/usr/local/apache/bin/apxs PATH=$PATH:/usr/local/apache/bin passenger-install-apache2-module Welcome to the Phusion Passenger Apache 2 module installer, v2.2.5. This installer will guide you through the entire installation process. It shouldn't take more than 3 minutes in total. Here's what you can expect from the installation process: 1. The Apache 2 module will be installed for you. 2. You'll learn how to configure Apache. 3. You'll learn how to deploy a Ruby on Rails application. Don't worry if anything goes wrong. This installer will advise you on how to solve any problems. Press Enter to continue, or Ctrl-C to abort.
Hit enter and the installer will compile the Apache 2 module. If this is successful you will get a message with directions for modifying the Apache conf:
The Apache 2 module was successfully installed. Please edit your Apache configuration file, and add these lines: LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5 PassengerRuby /usr/bin/ruby After you restart Apache, you are ready to deploy any number of Ruby on Rails applications on Apache, without any further Ruby on Rails-specific configuration! Press ENTER to continue.
Copy the configuration directives and place them in /usr/local/apache/conf/includes/pre_main_global.conf. Do not directly edit the httpd.conf!
These are the lines that should be added (with server-specific version numbers):
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5 PassengerRuby /usr/bin/ruby
Add the following to the httpd.conf (passenger docs):
PassengerResolveSymlinksInDocumentRoot on
Run the httpd.conf config distiller to save these changes:
root@host:[~]$ /usr/local/cpanel/bin/apache_conf_distiller --update Distilled successfully
Then rebuild the httpd.conf using the cPanel rebuild script. Stop and correct any errors before restarting Apache:
root@host:[~]$ /scripts/rebuildhttpdconf Built /usr/local/apache/conf/httpd.conf OK
Restart Apache and verify Passenger is installed by running this command:
root@host:[~]$ apachectl -t -D DUMP_MODULES
Check for ‘passenger_module (shared)’.
By default, RailsAutoDetect is on so it will detect a directory that is a Rails application. If this is off, you will need to add a custom vhost configuration to let Apache know to load Passenger for a particular site. To do this add the following to the site’s vhost container:
RailsBaseURI /
(or whatever URI is the base of the application)
Directions for adding custom directives to a vhost in cPanel: Add Custom Apache Directives to a vhost in cPanel
If the Rails application will be the root of the site, you will need to create a symlink from the Rails application’s public directory to /home/[username]/public_html.






