passenger_ruby path-to-ruby-interpreter;

passenger_ruby ruby;


http, server, location, if

The passenger_ruby option specifies the Ruby interpreter to use for serving Ruby web applications.

In addition, the passenger_ruby option in the http context also specifies which Ruby interpreter to use for Passenger’s internal Ruby helper tools, e.g. the one used by passenger_pre_start. See Lightweight Ruby dependency for more information about the internal Ruby helper tools.

If passenger_ruby is not specified, then it defaults to ruby, which means that the first ruby command found in PATH will be used.

Closely related to passenger_ruby is passenger_python, passenger_nodejs, etc. The following example illustrates how it works and how you can use these options to specify different interpreters for different web apps.

Copyhttp {
    passenger_root ...;

    # Use Ruby 2.1 by default.
    passenger_ruby /usr/bin/ruby2.1;
    # Use Python 2.6 by default.
    passenger_python /usr/bin/python2.6;
    # Use /usr/bin/node by default.
    passenger_nodejs /usr/bin/node;

    server {
        # This Rails web app will use Ruby 2.1
        listen 80;
        root /webapps/foo/public;

    server {
        # This Rails web app will use Ruby 2.2.1, as installed by RVM
        passenger_ruby /usr/local/rvm/wrappers/ruby-2.2.1/ruby;

        listen 80;
        root /webapps/bar/public;

        # If you have a web app deployed in a sub-URI, customize
        # passenger_ruby/passenger_python inside a `location` block.
        # The web app under will use JRuby 1.7.1
        location ~ ^/blog(/.*|$) {
            alias /websites/blog/public$1;
            passenger_base_uri /blog;
            passenger_app_root /websites/blog;
            passenger_document_root /websites/blog/public;
            passenger_enabled on;
            passenger_ruby /usr/local/rvm/wrappers/jruby-1.7.1/ruby;

    server {
        # This Flask web app will use Python 3.0
        passenger_python /usr/bin/python3.0;

        listen 80;
        root /webapps/baz/public;
Notes about multiple Ruby interpreters

If your system has multiple Ruby interpreters, then it is important that you set this configuration option to the right value. If you do not set this configuration option correctly, and your app is run under the wrong Ruby interpreter, then all sorts of things may go wrong, such as:

  • The app won’t be able to find its installed gems.
  • The app won’t be able to run because of syntax and feature differences between Ruby versions.

Note that a different RVM gemset also counts as “a different Ruby interpreter”.

How to set the correct value

If you are not sure what value to set passenger_ruby to, then you can find out the correct value as follows.

First, find out the location to the passenger-config tool and take note of it:

Copy$ which passenger-config

Next, activate the Ruby interpreter (and if applicable, the gemset) you want to use. For example, if you are on RVM and you use Ruby 2.2.1, you may want to run this:

Copy$ rvm use 2.2.1

Finally, invoke passenger-config with its full path, passing --ruby-command as parameter:

Copy$ /opt/passenger/bin/passenger-config --ruby-command
passenger-config was invoked through the following Ruby interpreter:
  Command: /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby
  Version: ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
  To use in Apache: PassengerRuby /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby
  To use in Nginx : passenger_ruby /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby
  To use with Standalone: /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby /opt/passenger/bin/passenger start

## Notes for RVM users
Do you want to know which command to use for a different Ruby interpreter? 'rvm use' that Ruby interpreter, then re-run 'passenger-config --ruby-command'.

The output tells you what value to set.

此条目发表在学习笔记分类目录,贴了, , 标签。将固定链接加入收藏夹。