Phusion Passenger, Nginx and a Rails 3.2 application

nginxI am just in the process of making a new Rails application live. I use RVM to manage my ruby environments and I'm currently running ruby 1.9.3. I am deploying on Nginx 1.0.11 and Phusion Passenger 3.0.11 (mod_rails/mod_rack). I followed the usual configuration instructions and restarted the nginx server. When I tried to start the application by accessing the URL in my browser I received an error saying that bundle could not be found. After a lot of trial and error I finally realised I had made a mistake in my nginx.conf file.

This was my original nginx.conf file. I configured this by pulling the settings from rvm info.
http {
passenger_root /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11;
passenger_ruby /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby;
...
}

Whilst "rubies/ruby-xxx/bin/ruby" is what rvm was telling was the path to ruby, what I should have been using is the rvm wrapper around ruby:
http {
    passenger_root /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11;
    passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby;
...
}

Glad to say that the application started fine after I worked this out.