Installing Passenger when Nginx is already installed; Possible?
Asked Answered
S

6

15

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;
}
Slimy answered 30/9, 2011 at 15:37 Comment(0)
S
17

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.

Stoffel answered 8/10, 2011 at 19:51 Comment(1)
after a looong time searching, this is the solution! tksHom
R
2

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).

Rothstein answered 6/1, 2014 at 21:35 Comment(0)
S
0

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.

Subtotal answered 18/9, 2015 at 7:41 Comment(1)
I haven't tried this, but the solution is highly unlikely to work since NGINX requires modules at build/make -- unlike apache.Golden
M
0

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.

Mozarab answered 10/6, 2016 at 12:41 Comment(0)
P
0

There is a way install nginx passenger module without reinstalling/recompiling nginx

https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/bionic/install_passenger.html

Picard answered 8/3, 2020 at 16:18 Comment(0)
D
-2

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

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

Dendroid answered 30/9, 2011 at 16:22 Comment(1)
That is not quite the solution afaik. I have a server block with that statement (I updated) the question with that blockSlimy

© 2022 - 2024 — McMap. All rights reserved.