Installing Passenger when Nginx is already installed; Possible?

Rather a simple question I believe, is it possible to install passenger when nginx is already installed on your webserver?

If the answer is Yes, I already performed these actions:

At this very moment I already have nginx installed (for my PHP applications) and next I did a checkout of the passenger's git repository:

mkdir /repositories
cd /repositories/
git clone https://github.com/FooBarWidget/passenger.git
cd passenger/

and then add this snippet to /etc/nginx/conf/nginx.conf

  http {
      ...
      passenger_root /repositories/passenger;
      passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-p290/ruby;
      ...
  }

However when I want to restart nginx I get the following error:

* Starting Web Server nginx
nginx: [emerg] unknown directive "passenger_root" in /etc/nginx/nginx.conf:19

Which concludes me to say that there is still some config I need to set, for nginx to be aware that we're using passenger.

My server block

server {
  listen 80;
  server_name rails.kreatude.com;
  root /srv/www/my_test_app;
  passenger_enabled on;
}

Answers


I think your problem is that the passenger module is not present in nginx.

All the passenger dependent directives you've described (passenger_root, passenger_ruby, passenger_enabled) are available only when the passenger module is attached to nginx. This is why you have to compile nginx with --add-module='/path/to/passenger-3.0.9/ext/nginx'.

Unfortunately, I don't know of any method to enable passenger module without re-installing nginx. But, according to http://wiki.nginx.org/Modules, "Nginx modules must be selected at compile-time.", so there could be a chance that there isn't a way to do that.


In Passenger docs the chapter "Generic installation, upgrade and downgrade method: via RubyGems" discusses this. Basically, once the Passenger gem is installed, nginx needs to be recompiled (and then used instead of the yum/apt-get-installed nginx if one exists). Passenger's compilation/configuration utility "passenger-install-nginx-module" does it for you (it's part of the Passenger gem), and it automatically includes the necessary switches for Passenger. It also gives you the option to add your own switches (such as for extra modules, or to enable/disable NGiNX's built-in features).


With rvm, you could do this simply by running rvmsudo passenger-install-nginx-module.

For more detail: https://www.digitalocean.com/community/tutorials/how-to-install-rails-and-nginx-with-passenger-on-ubuntu.


I confirm ion-br's answer, I'm facing the same kind of problems and PhusionPassenger's site states:

Before you begin, you should know that installing Passenger in its Nginx integration mode involves extending Nginx with code from Passenger. However, Nginx does not support loadable modules. This means that in order to install Passenger's Nginx integration mode, it is necessary to recompile Nginx from source.

The only solution is thus to properly reinstall Nginx, if your machine is an AWS AMI instance the solution lies here.


passenger_enabled on; in server, http, or location block.

http://modrails.com/documentation/Users%20guide%20Nginx.html#_important_deployment_options


Need Your Help

Yet Another crosdomain.xml question or: "How to interpret documentation correctly"

apache-flex flash cross-domain crossdomain.xml

I have read a lot about the new policy-policy of flash player and also know the master policy file.