title: Phusion Passenger Web application could not be started / picks wrong ruby
body: <p>My RoR app fails to start, with error: </p>
  
  <blockquote>
    <p>It looks like Bundler could not find a gem. Maybe you didn't install
    all the gems that this application needs. To install your gems, please
    run:</p>
    
    <p>bundle install</p>
    
    <p>If that didn't work, then the problem is probably caused by your
    application being run under a different environment than it's supposed
    to. Please check the following:</p>
  
  <pre><code>Is this app supposed to be run as the railsapp user?
  Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.
  </code></pre>
  </blockquote>
  
  <p>and</p>
  
  <pre><code>Ruby interpreter command
  
      /usr/bin/ruby1.8
  </code></pre>
  
  <p>The file config/environment.rb is owned by the railsapp user. 
  I use rbenv, and installed ruby version 2.1.1 as the global version. 
  I use bundler to install the gem dependencies. which is all OK. </p>
  
  <p>So it seems, phusion passenger picks the wrong ruby version (At least not the one I installed as global with rbenv). </p>
  
  <h2>How do I make Phusion passenger compile mod_rails with the ruby version installed with rbenv?</h2>
  
  <p>when I ran: passenger-install-apache2-module, I noticed it picked up the system installed ruby version from ubuntu as: </p>
  
  <pre><code>* Checking for Ruby development headers...
        Found: yes
        Location: /usr/lib/ruby/1.8/i486-linux/ruby.h
  </code></pre>
  
  <p>but 'which ruby' as railsapp user gives this: </p>
  
  <pre><code>/home/railsapp/.rbenv/shims/ruby
  </code></pre>
  
  <p>My gem environment is like this: </p>
  
  <pre><code>RubyGems Environment:
    - RUBYGEMS VERSION: 2.2.2
    - RUBY VERSION: 2.1.1 (2014-02-24 patchlevel 76) [i686-linux]
    - INSTALLATION DIRECTORY: /home/railsapp/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0
    - RUBY EXECUTABLE: /home/railsapp/.rbenv/versions/2.1.1/bin/ruby
    - EXECUTABLE DIRECTORY: /home/railsapp/.rbenv/versions/2.1.1/bin
    - SPEC CACHE DIRECTORY: /home/railsapp/.gem/specs
    - RUBYGEMS PLATFORMS:
      - ruby
      - x86-linux
    - GEM PATHS:
       - /home/railsapp/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0
       - /home/railsapp/.gem/ruby/2.1.0
    - GEM CONFIGURATION:
       - :update_sources =&gt; true
       - :verbose =&gt; true
       - :backtrace =&gt; false
       - :bulk_threshold =&gt; 1000
    - REMOTE SOURCES:
       - https://rubygems.org/
    - SHELL PATH:
       - /home/railsapp/.rbenv/versions/2.1.1/bin
       - /etc/rbenv/libexec
       - /home/railsapp/.rbenv/shims
       - /etc/rbenv/bin
       - /usr/local/sbin
       - /usr/local/bin
       - /usr/sbin
       - /usr/bin
       - /sbin
       - /bin
       - /usr/games
  </code></pre>