Passenger + Nginx

158 views
Skip to first unread message

Birimblongas

unread,
May 25, 2015, 7:01:26 PM5/25/15
to phusion-...@googlegroups.com
Hi, i don't know if you can, by any chance, help me.
But i'm trying to config my app from unicorn + nginx to passenger 5.0 (raptor) + nginx (i've used nginx-passenger module to install it).

I've changed my .conf files from nginx to  have the lines below but, i'm still getting error and the passenger wont start and wont start my app. (nginx start tho)

passenger_enabled on;
passenger_root [my path]/.rvm/gems/ruby-2.1.0/gems/passenger-5.0.8;
passenger_ruby [my path]/.rvm/gems/ruby-2.1.0/wrappers/ruby;

which passenger_root and passenger_ruby paths are the one indicated after installing nginx with passenger command.

my server doesn't recognizes passenger_ruby command and every time i try to access my app, i get the error: [error] ... connect() to unix:/tmp/.app.sock failed (111: Connection refused) while connecting to upstream,

My .conf files from nginx are basically following the default + some necessary info from my app.

If i force to initiate my app with rails s, for example, i get the error of already using the port i mention on .conf file. So i'm supossing that the server is started at the location and port. But it's not finding my app. With unicorn it was working normally, so it's not a problem in the nginx conf about the app. I beleave that it's something about passenger that's missing, but don't know what.


Can you help me at all?


Hongli Lai

unread,
May 26, 2015, 6:35:35 AM5/26/15
to phusion-passenger
I get the feeling that, upon installing Passenger, you ended up with
multiple Nginx installations on your system. And that you were
expecting to start a specific Nginx installation, but actually started
the other (which uses a whole different configuration file) and got
confused. Can you check whether that is the case? This wiki page has
more information:
https://github.com/phusion/passenger/wiki/Why-can't-Phusion-Passenger-extend-my-existing-Nginx%3F

On Tue, May 26, 2015 at 1:01 AM, Birimblongas <bianca....@gmail.com> wrote:
> Hi, i don't know if you can, by any chance, help me.
> But i'm trying to config my app from unicorn + nginx to passenger 5.0
> (raptor) + nginx.
>
> I've changed my .conf files from nginx to have the lines below but, i'm
> still getting error and the passenger wont start and wont start my app.
> (nginx start tho)
>
> passenger_enabled on;
> passenger_root [my path]/.rvm/gems/ruby-2.1.0/gems/passenger-5.0.8;
> passenger_ruby [my path]/.rvm/gems/ruby-2.1.0/wrappers/ruby;
>
> which passenger_root and passenger_ruby paths are the one indicated after
> installing nginx with passenger command.
>
> my server doesn't recognizes passenger_ruby command and every time i try to
> access my app, i get the error: [error] ... connect() to unix:/tmp/.app.sock
> failed (111: Connection refused) while connecting to upstream,
>
> My .conf files from nginx are basically following the default + some
> necessary info from my app.
>
> If i force to initiate my app with rails s, for example, i get the error of
> already using the port i mention on .conf file. So i'm supossing that the
> server is started at the location and port. But it's not finding my app.
> With unicorn it was working normally, so it's not a problem in the nginx
> conf about the app. I beleave that it's something about passenger that's
> missing, but don't know what.
>
>
> Can you help me at all?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Phusion Passenger Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to phusion-passen...@googlegroups.com.
> To post to this group, send email to phusion-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/phusion-passenger.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/phusion-passenger/8aa2b611-d557-4eb5-a679-2d45457d7e95%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Phusion | Web Application deployment, scaling, and monitoring solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Birimblongas

unread,
May 26, 2015, 7:00:18 AM5/26/15
to phusion-...@googlegroups.com, hon...@phusion.nl
Thanks, but before i've installed nginx with passenger i've removed it... 

Anyway, i've followed the link steps again, removed nginx, re-installed even usen suggested path as /opt and the passenger doesn't start.

Hongli Lai

unread,
May 26, 2015, 7:26:08 AM5/26/15
to Birimblongas, phusion-passenger
Well, let's double check it. Can you answer these questions:
1. What is the full filename of your Nginx configuration file?
2. Run 'ps auxw | grep nginx'. What do you see?

Birimblongas

unread,
May 26, 2015, 7:31:00 AM5/26/15
to phusion-...@googlegroups.com, hon...@phusion.nl
1. [path]/conf/nginx.conf
2. two processes, a nginx worker process and a nginx master process. the last one with [path]/sbin/nginx

Birimblongas

unread,
May 26, 2015, 7:35:28 AM5/26/15
to phusion-...@googlegroups.com, hon...@phusion.nl
After changing my upstream socket path, my error have changed. It says that my .sock file doesn't exists. But i beleave it doesn't exists because the passenger is not started to create it. Right?

Hongli Lai

unread,
May 26, 2015, 7:40:48 AM5/26/15
to Birimblongas, phusion-passenger
On Tue, May 26, 2015 at 1:35 PM, Birimblongas <bianca....@gmail.com> wrote:
> After changing my upstream socket path, my error have changed. It says that
> my .sock file doesn't exists. But i beleave it doesn't exists because the
> passenger is not started to create it. Right?

No. The .sock file in the error message doesn't even seem to be a
Passenger socket file.

Can you post your entire Nginx config file for inspection?

Can you also tell me what you see if you run '[path]/sbin/nginx -V'?

Birimblongas

unread,
May 26, 2015, 7:48:54 AM5/26/15
to phusion-...@googlegroups.com, hon...@phusion.nl
my conf file is pretty much the default:

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    passenger_root /usr/lib/ruby/1.8/phusion_passenger/locations.ini;
    passenger_ruby /usr/bin/ruby;

    include       mime.types;
    default_type  application/octet-stream;
    include /etc/nginx/conf.d/app_conf.conf;
    sendfile        on;
    keepalive_timeout  65;
}

And my app_conf.conf:
upstream app_conf {
  server unix:/opt/nginx/sockets/.app_conf.sock;
}
server {
  listen 80 default_server;
  server_name _;
  root [app_path]/public;
  passenger_enabled on;
  try_files $uri/index.html $uri.html $uri @app;
  location = /favicon.ico {
    expires    max;
    add_header Cache-Control public;
  }
  location @app {
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://app_conf;
  }


  error_page 500 502 503 504 /500.html;

  location = /500.html {
    root [app_path]/public;
  }
}


and running nginx -V:

nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) 
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-cc-opt=-Wno-error --with-pcre=/tmp/passenger.1bwzkla/pcre-8.34 --add-module=/usr/share/passenger/ngx_http_passenger_module

Hongli Lai

unread,
May 26, 2015, 7:51:45 AM5/26/15
to Birimblongas, phusion-passenger
I see you have leftover reverse proxy configs that are interfering
with Passenger. You need to remove them. In particular, remove the
'try_files' and the 'location @app' block.

Birimblongas

unread,
May 26, 2015, 8:56:51 AM5/26/15
to phusion-...@googlegroups.com, hon...@phusion.nl
Hi,

i've done what you've said, also have uninstalled nginx and passanger beceause whas installed on wrong ruby version, now is a right one. 

Also i've added rails_env development to my .conf file and now it's working :D

Thank you!

Hongli Lai

unread,
May 26, 2015, 9:51:29 AM5/26/15
to phusion-passenger
What do you mean by "Passenger not starting my app"? What do you see
now in your web browser when you access Nginx?

On Tue, May 26, 2015 at 2:56 PM, Birimblongas <bianca....@gmail.com> wrote:
> Hi,
>
> i've done what you've said, also have uninstalled nginx and passanger
> beceause whas installed on wrong ruby version, now is a right one. But
> passenger still not starting my app and i don't get any error at nginx
> log... Nginx have started...
> --
> You received this message because you are subscribed to the Google Groups
> "Phusion Passenger Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to phusion-passen...@googlegroups.com.
> To post to this group, send email to phusion-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/phusion-passenger.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/phusion-passenger/002699cd-5f3c-4ace-853d-a50a03074bbe%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



Birimblongas

unread,
May 26, 2015, 9:55:38 AM5/26/15
to phusion-...@googlegroups.com, hon...@phusion.nl
I see my app running. Actually, your response was for my post before i've updated it. :x

If i run ps aux | grep nginx, i get my nginx workers.
But if i run ps aux | grep to ruby, rails or passenger nothing comes up. However, my app is running.

This is the normal behavior?

Hongli Lai

unread,
May 26, 2015, 10:01:49 AM5/26/15
to phusion-passenger
Ruby apps spawned by Passenger have the process title "Passenger
RubyApp: ...". Grep is case-sensitive by default so you didn't see it.
In any case, don't use ps for check on Passenger/Ruby processes. Use
these tools:

- passenger-memory-stats
- passenger-status

They are more convenient, report more information and report them more
accurately.

On Tue, May 26, 2015 at 3:55 PM, Birimblongas <bianca....@gmail.com> wrote:
> I see my app running.
>
> https://groups.google.com/d/msgid/phusion-passenger/a46b7a3a-09d8-4945-bf5b-f45a7a639e73%40googlegroups.com.

Birimblongas

unread,
May 26, 2015, 10:04:16 AM5/26/15
to phusion-...@googlegroups.com, hon...@phusion.nl
That's true. Thanks

How do I update only passenger workers?
If, for example, i make a change at my app and want to update the server without stoping and starting nginx...

Hongli Lai

unread,
May 26, 2015, 10:13:24 AM5/26/15
to Birimblongas, phusion-passenger
On Tue, May 26, 2015 at 4:04 PM, Birimblongas <bianca....@gmail.com> wrote:
> That's true. Thanks
>
> How do I update only passenger workers?

It's described here:
https://www.phusionpassenger.com/library/walkthroughs/basics/ruby/reloading_code.html

Birimblongas

unread,
May 26, 2015, 10:32:07 AM5/26/15
to phusion-...@googlegroups.com, hon...@phusion.nl
Awesome. Thanks again
Reply all
Reply to author
Forward
0 new messages