Starting phusion passenger on working apache

apache-2.2phusion-passengerrubysinatra

I've got Apache (-v):

Server version: Apache/2.0.63
Server built:   Nov 29 2009 15:23:34
Cpanel::Easy::Apache v3.2.0 rev4899

I want to start new Sinatra application on passenger. I've just installed passenger gem. So now I need to set up apache configuration.

In httpd.conf there are many settings of others applications on server. So I just can't reinstall apache with passenger-install-apache2-module. I need to set up exist Apache with passenger. What have I do now?

Best Answer

Step one: run passenger-install-apache2-module as root. This will install the passenger module, which is required.

Step two: The passenger-install-apache2-module script will tell you what to add to httpd.conf. Add it. It should not affect any other applications you are running.

Step three: For each Ruby on Rails or Sinatra app, configure it in Apache. I do this for Sinatra apps:

<VirtualHost *:80>
  ServerName hman.flame.org
  DocumentRoot /www/hman/current/public
  ExpiresDefault "access plus 10 years"
</VirtualHost>

I then have config.ru in /www/hman/current which is detected by Passenger automatically.

For Rails apps:

<VirtualHost *:80>
  ServerName art.waywardgypsy.com
  DocumentRoot /www/waywardgypsy-art/current/public
  ExpiresDefault "access plus 10 years"
</VirtualHost>

I then use Capistrano to deploy the Rails application to /www/waywardgypsy-art.

In both cases, the .../current/public directory has files which are static in nature such as images, CSS, etc. These are served directly from Apache. Passenger looks into the virtual host's config and checks for Sinatra or Rails, and if it finds the appropriate config file, it will treat it as the appropriate application framework.

Passenger will not affect virtual hosts which do not have a Sinatra config file (config.ru) or Rails (config/boot.rb).