====== Passenger ====== [[http://www.modrails.com/|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. ServerName www.myrailssite.co.uk DocumentRoot /var/www/railssite/current/public RailsEnv production 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: ServerName www.myrailssite.co.uk DocumentRoot /var/www RailsEnv production # set Rails environment RailsBaseURI /app # set application's base URI 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" ===== Please see http://blog.scopeport.org/ruby-on-rails/phusion-passenger-error-file-directory-nonexistent/ and the official cause http://rubyforge.org/tracker/index.php?func=detail&aid=23105&group_id=126&atid=577 . ====== Ruby Enterprise Edition ====== Phusion has also built a custom version of Ruby called [[http://www.rubyenterpriseedition.com/|Ruby Enterprise Edition]] that can be used with Passenger to decrease application memory usage, which is especially useful on shared or VPS hosting.