Ayrton Ayrton - 2 years ago 121
Linux Question

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

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;

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download