1. Install apache22

% cd /usr/ports/www/apache22
% make config
% make install clean
% vim /etc/rc.conf
apache22_enable=YES
/usr/local/etc/rc.d/apache22 start

2. Install rvm via multi user install from http://beginrescueend.com/rvm/install/

Login as root.
%  bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  799k  100  799k            109k        :00:07  :00:07 --:--:--  199k
 
Installing RVM to /usr/local/rvm/
    RVM system user group 'rvm' exists, proceeding with installation.
 
# RVM:  Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.beginrescueend.com/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Screencast: http://screencasts.org/episodes/how-to-use-rvm
 
# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'
 
Installation of RVM in /usr/local/rvm/ is almost complete:
 
  * First you need add all users that will be using rvm to 'rvm' group,
    anyone using rvm will be operating with `umask g+w`.
 
  * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
 
  * Optionally you can run `rvm tools rvm-env ruby bash` which will generate 
    shebang wrappers for easier selecting ruby in scripts.
 
# root,
#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne

3. Add your users to rvm group

# vim /etc/group
....
rvm:*:1003:root,rupert

Load rvm script to current shell by calling source /etc/profile.d/rvm.sh or add it to /etc/profile and re-login

#vim /etc/profile
source /etc/profile.d/rvm.sh

After relogging in, simply type rvm and it should spit out something. If the command is not found, then you are doing something wrong.

4. Install 1.9.3

% rvm install 1.9.3
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)...
 
ruby-1.9.3-p0 - #fetching 
ruby-1.9.3-p0 - #downloading ruby-1.9.3-p0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  3 8604k    3  340k    0     0  27173      0  0:05:24  0:00:12  0:05:12 64100

Use ruby1.9.3

% rvm --default use 1.9.3-p0
% gem install bundler -V

5. Install passenger3

This will install system wide passenger gem which is installed on 1.9.3-p0 gemset.

% gem install passenger -V

You should have at least the ff gems installed:

bundler (1.1.3)
daemon_controller (1.0.0)
fastthread (1.0.7)
passenger (3.0.12)
rack (1.4.1)
rake (0.9.2.2)
% cd /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11/bin
% ./passenger-install-apache2-module
--------------------------------------------
The Apache 2 module was successfully installed.
 
Please edit your Apache configuration file, and add these lines:
 
   LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11
   PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p0/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.
 
 
--------------------------------------------
Deploying a Ruby on Rails application: an example
 
Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:
 
   <VirtualHost *:80>
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
      <Directory /somewhere/public>
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      </Directory>
   </VirtualHost>

6. Edit httpd.conf to load the passenger module

To use a rvm gemset by passenger read “Rails app with custom .rvmrc and a system wide passenger install” https://rvm.beginrescueend.com/integration/passenger/

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p0/ruby
<VirtualHost 192.168.69.3:80>
   ServerAdmin rupert@2rmobile.com
   ServerName myserver
   ServerAlias myserver
 
   DocumentRoot "/path/to/myapp/public"
   <Directory "/path/to/myapp/public">
 
   #DocumentRoot "/path/to/myapp/current/public"
   #<Directory "/path/to/myapp/current/public">
      Options Indexes MultiViews
      AllowOverride None 
      Order allow,deny
      Allow from all 
   </Directory>
 
   CustomLog /var/log/apache22/myapp-error.log combinedio
   LogLevel warn 
</VirtualHost>

We need a railsapp/config/setup_load_paths.rb to use our custom .rvmrc

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
   begin
      rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
      rvm_lib_path = File.join(rvm_path, 'lib')
      $LOAD_PATH.unshift rvm_lib_path
      require 'rvm'
      RVM.use_from_path! File.dirname(File.dirname(__FILE__))
   rescue LoadError
      # RVM is unavailable at this point.
      raise "RVM ruby lib is currently unavailable."
   end
end
 
# Pick the lines for your version of Bundler
# If you're not using Bundler at all, remove all of them
 
# Require Bundler 1.0 
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'
 
# Require Bundler 0/9
# if File.exist?(".bundle/environment.rb")
#   require '.bundle/environment'
# else
#   require 'rubygems'
#   require 'bundler'
#   Bundler.setup
# end

Visit this stackoverflow question http://stackoverflow.com/questions/5680341/how-to-load-passenger-from-apache-with-rvm-and-unique-gem-sets

% git clone rupert@server:/path/to/your/myapp.git
% cd myapp

9. Run bundle

% bundle install -V
Fetching source index for http://rubygems.org/
....

Errors that you may encounter

Note: The rvmrc located in ‘../releases/20120208034235′ could not be loaded, likely due to trust mechanisms. Please run ‘rvm rvmrc {trust,untrust} “../releases/20120208034235″‘ to continue, or set rvm_trust_rvmrcs_flag to 1. (RVM::ErrorLoadingRVMRC)

% vim /etc/rvmrc
umask g+w
rvm_trust_rvmrcs_flag=1