Translations of this page?:

Passenger

Phusion Passenger (aka mod_rails) is an easy way to deploy your application on a web server. It's almost as easy as deploying a PHP application, simply upload your app into the directory on the web server, create a tmp/restart.txt and you're done.

Passenger replaces the need to manage maintaining several mongrel or thin processes, load balancing across and maintaining the availability (stop/start/polling) of those processes. Instead it does all of that internally spawning as many ruby processes as needed to deal with the current load and killing them if the site if effectively unused. The benefits of a greatly simplified means of deploying your Rails app are clear.

Installation

Passenger requires the Apache 2 web server.

Start by installing Phusion Passenger via RubyGems:

$ sudo gem install passenger
$ sudo passenger-install-apache2-module

Follow the instructions as provided by the installation script. In most cases, the default values will work. The lines you'll be adding to your Apache config file will look something like this:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/bin/ruby1.8

Note: the above code is just an example, copy whatever the installer tells you to copy.

Once you have followed the instructions to configure the passenger module for your environment and have restarted Apache you are ready to configure your VirtualHost.

Configuration

Deploying to a virtual host's root

To deploy to a virtual host's root set the Apache document root to the public directory of your application.

<VirtualHost *>
  ServerName www.myrailssite.co.uk
  DocumentRoot /var/www/railssite/current/public
  RailsEnv production
</VirtualHost>

Passenger should now recognize the rails application and start it on the first access.

Deploying to a sub URI

To deploy to a sub URI of an existing virtual host edit its configuration file:

<VirtualHost *>
    ServerName www.myrailssite.co.uk
    DocumentRoot /var/www
    RailsEnv production    # set Rails environment
    RailsBaseURI /app    # set application's base URI
</VirtualHost>

where /var/www/app is a symlink to the public directory of your application:

$ sudo ln -s /home/rails/myapp/public /var/www/app

add this line to your application's config/environment.rb file:

Rails::Initializer.run do |config|
    ...
    config.action_controller.relative_url_root = '/app'    # add this
end

and then restart the Apache server.

Passenger should now recognize the rails application and start it on the first access.

Documentation on all the configuration options available can be found here: http://www.modrails.com/documentation/Users%20guide.html

"No such file or directory - /nonexistent"

Ruby Enterprise Edition

Phusion has also built a custom version of Ruby called Ruby Enterprise Edition that can be used with Passenger to decrease application memory usage, which is especially useful on shared or VPS hosting.

Discussion

Tibi Turbureanu, 2009/05/15 10:43

I found myself in the impossibility to deploy my application to a sub URI and learned that people have this common problem and complain on IRC, lists and forums.

I finally managed to get my application to work, based on the solution posted on this thread: http://groups.google.com/group/phusion-passenger/browse_thread/thread/9ec28ebf3409bbaa

That's why I added the section Deploying to a sub URI.

 
deployment/apache-passenger.txt · Last modified: 2009/05/15 10:38 by tct
 
Recent changes RSS feed Creative Commons License