I spent more than a day stuck with using phusion passenger for a production deployment of an app I made for a client. This is a short note to remind myself of it in future and to help anyone stuck with the same.
The symptoms were pretty bad. Phusion passenger “simply did not work” with nginx. The standalone mode works like a charm, but nginx integration mode gives me directory listings, serves files in public, but does not start the app at all. Nothing in nginx logs to help. The server config is perfectly fine, checked it a hundred times, and tried a bazillion variations.
The problem: A missing passenger_root directive in http block of nginx.conf. I haven’t found anywhere that it is necessary, and given that I used phusion passenger’s repository to install nginx and passenger, I expected the setup to work out of the box.
If your passenger-deployed app doesn’t seem to start at all, just check if your http block has the passenger_root directive. In my case, it had to be set to /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini. It might be different in your case, just do a locate phusion_passenger/locations.ini to get the appropriate path.
After two days of scratching my head, reading through nginx and passenger docs a dozen times, just added it on a whim and it now works! I can now sleep in peace.
Also, look at passenger_nodejs if you use nvm. You don’t need system-wide node if your passenger_nodejs points to the proper node binary.
This post also highlighted the need for better config If I intend to blog about code. Not being able to visually distinguish code-snippets and inlined commands is a big bummer.