Bitnami Phusion Passenger

NOTE: Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under "Start -> Bitnami APPNAME Stack -> Application console" (Windows). Learn more.

Phusion Passenger is a Web and application server, commonly used with Ruby on Rails applications.

How to change the default URL with Phusion Passenger?

Follow these steps:

  • Ensure that Phusion Passenger is enabled (instructions).

  • Replace the content of the file installdir/apps/application/conf/application.conf with the following:

     <VirtualHost *:80>
       DocumentRoot installdir/apps/application/public
       <Directory installdir/apps/application/public/>
         PassengerEnabled on
         Options -MultiViews
         <IfVersion < 2.3 >
         Order allow,deny
         Allow from all
         </IfVersion>
         <IfVersion >= 2.3>
         Require all granted
         </IfVersion>
       </Directory>
     </VirtualHost>
    
  • Restart the Apache server:

     $ sudo installdir/ctlscript.sh restart apache
    

How to configure Apache with Phusion Passenger?

To enable Phusion Passenger, follow these steps:

  • Check that the following line is uncommented in the Apache configuration file at installdir/apache2/con/httpd.conf:

     Include conf/bitnami/passenger.conf
    
  • Assuming your application is running at the URL prefix /application, substitute the content of the file installdir/apps/application/conf/application.conf with the following:

     <VirtualHost *:80>
       PassengerEnabled on
       RailsBaseURI /application
       <Directory installdir/apache2/htdocs/application>
         Options -MultiViews
       </Directory>
     </VirtualHost>
    
  • Log in to your server console and create a symbolic link:

     $ sudo ln -s installdir/apps/application/public installdir/apache2/htdocs/application
    

    Ensure that the public and config application folders and their parent directories are readable and executable by the Apache user.

  • Restart the Apache server:

     $ sudo installdir/ctlscript.sh restart apache
    

How to configure Nginx with Phusion Passenger to run Ruby on Rails applications?

Follow these steps:

  • Stop the Apache service:

     $ installdir/ctlscript.sh stop apache
    
  • Modify the server configuration in the installdir/nginx/conf/nginx.conf file so that it looks similar to this:

     server {
         listen 80;
         server_name example.com;
         root installdir/apps;
         passenger_enabled on;
    
         pagespeed on;
         pagespeed FileCachePath installdir/nginx/var/ngx_pagespeed_cache;
    
         #  Ensure requests for pagespeed optimized resources go to the pagespeed
         #  handler and no extraneous headers get set.
         location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
         location ~ "^/ngx_pagespeed_static/" { }
         location ~ "^/ngx_pagespeed_beacon$" { }
         location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
         location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }
     }
    

    With this code, you will be running your Ruby on Rails application at the root of your domain, and will be running through the default HTTP port (80). Before restarting Nginx to apply this configuration, we recommend disabling Apache from starting by default.

    To do this, run these commands:

     $ installdir/ctlscript.sh stop apache
     $ mv installdir/apache2/scripts/ctl.sh installdir/apache2/scripts/ctl.sh.disabled
     $ mv installdir/config/monit/conf.d/apache.conf installdir/config/monit/apache.conf.disabled
    
  • Restart the Nginx service to apply the new configuration:

     $ installdir/ctlscript.sh restart nginx
    

Access your Ruby on Rails applications with Nginx and Passenger at http://localhost/.

How to fix Passenger errors on Mac OS X 10.11 El Capitan?

IMPORTANT: If you are using Mac OS X and you upgraded to Mac OS X 10.11 "El Capitan", perform the following steps in order to continue using Passenger. This is required because of the new System Integrity Protection feature.

Follow these steps:

  • Navigate to your stack installation directory (eg. /Applications/redmine-3.1.1-0/) and stop the servers using the graphical manager.

  • Rename the PassengerAgent binary to *PassengerAgent.bin". When using the terminal, this is the command:

     $ mv /Applications/redmine-3.1.1-0/ruby/lib/ruby/gems/2.0.0/gems/passenger-5.0.6/buildout/support-binaries/PassengerAgent /Applications/redmine-3.1.1-0/ruby/lib/ruby/gems/2.0.0/gems/passenger-5.0.6/buildout/support-binaries/PassengerAgent.bin
    
  • Create a new file in the same location named PassengerAgent with the following content:

     #!/bin/sh
    
     . /Applications/redmine-3.1.1-0/scripts/setenv.sh
    
     exec /Applications/redmine-3.1.1-0/ruby/lib/ruby/gems/2.0.0/gems/passenger-5.0.6/buildout/support-binaries/PassengerAgent.bin"$@"
    
  • Change the permissions of the new file:

     $ chmod 755 /Applications/redmine-3.1.1-0/ruby/lib/ruby/gems/2.0.0/gems/passenger-5.0.6/buildout/support-binaries/PassengerAgent
    
  • Restart the server using the graphical manager.

NOTE: When running the commands shown on this page, replace the installdir placeholder with the full installation directory for your Bitnami stack.
nativeInstaller

Bitnami Documentation