David - Musings of an SRE

Getting Passenger_pre_start to load Rails Apps on load

If you’re like me and you’ve already set:

passenger_pre_start http://somesite_to_load/;

But yet your application doesn’t load up on restart.

Fret not, its probably because your pathing is screwed.

To troubleshoot, take a look at your nginx error.log.

You’ll probably see something like this even after you restart:

# /opt/nginx/logs/error.log
/usr/bin/env: ruby: No such file or directory

This is because nginx is trying to load your site using ruby and you don’t have ruby in your path.

To solve this, in your /etc/init.d/nginx script, add the path to your passenger ruby instance.

# /etc/init.d/nginx
PATH=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin

Reference:

Phusion Passenger Mailing List