0

I'm upgrading to a new linode with Debian. I installed rvm, ruby enterprise edition, passenger, nginx (via passenger), rails 2.3 lts. My app works with script/server. I got nginx to serve static files. But nginx acts like passenger doesn't exist when I go to a rails route. I made a fresh test app, and a simplified nginx.conf, with the same result. I see no errors from passenger in the log.

The basic problem is nginx looks for a static file instead of spawning rails:

2016/01/01 17:18:00 [error] 4820#0: *10 open() "/home/curi/www/testapp/public/test/foo" failed (2: No such file or directory), client: 73.241.61.62, server: , request: "GET /test/foo HTTP/1.1", host: "45.79.64.233"

I read the 3 solutions at https://www.phusionpassenger.com/library/admin/nginx/troubleshooting/ruby/ and googled a lot, but I'm still stuck. Details:

sample nginx error log with passenger log level 3:

[ 2016-01-01 12:10:34.3961 3468/7efdc8705780 age/Wat/WatchdogMain.cpp:1276 ]: Starting Passenger watchdog...
[ 2016-01-01 12:10:34.4108 3474/7fdae531f780 age/Cor/CoreMain.cpp:957 ]: Starting Passenger core...
[ 2016-01-01 12:10:34.4111 3474/7fdae531f780 age/Cor/CoreMain.cpp:234 ]: Passenger core running in multi-application mode.
[ 2016-01-01 12:10:34.4127 3474/7fdae531f780 age/Cor/CoreMain.cpp:707 ]: Passenger core online, PID 3474
[ 2016-01-01 12:10:34.4232 3482/7f90f019e780 age/Ust/UstRouterMain.cpp:504 ]: Starting Passenger UstRouter...
[ 2016-01-01 12:10:34.4238 3482/7f90f019e780 age/Ust/UstRouterMain.cpp:317 ]: Passenger UstRouter online, PID 3482
2016/01/01 12:10:44 [error] 3494#0: *2 open() "/home/curi/www/curius/current/public/1" failed (2: No such file or directory), client: 73.241.61.62, server: , request: "GET /1 HTTP/1.1", host: "45.79.64.233"

passenger log level 7, did a restart and tried to load a sample app page:

http://pastebin.com/Kr6Ccx9T

nginx.conf:

worker_processes  1; # nginx workers

events {
    worker_connections  1024;
}

http {
    passenger_root /home/curi/.rvm/gems/ree-1.8.7-2012.02/gems/passenger-5.0.23;
    passenger_ruby /home/curi/.rvm/gems/ree-1.8.7-2012.02/wrappers/ruby;
    # passenger_ruby /home/curi/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby; # i tried both
    passenger_log_level 7; # 3 default, 7 max
    rewrite_log  on;
    error_log  logs/error.log  notice;


   server {
      listen 80 default_server;
      root /home/curi/www/testapp/public;   # <--- be sure to point to 'public'!
      passenger_enabled on;
      rails_env production;
   }
}

I did try it with server_name set, too. And I tried it with my more complex, working conf from my old server (just passenger_root and passenger_ruby changed). Same results.

Versions:

curi@curius:/opt/nginx/logs$ nginx -V
nginx version: nginx/1.8.0
built by gcc 4.9.2 (Debian 4.9.2-10) 
built with OpenSSL 1.0.1k 8 Jan 2015
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-ld-opt= --with-pcre=/tmp/passenger.1n7nxq7/pcre-8.34 --add-module=/home/curi/.rvm/gems/ree-1.8.7-2012.02/gems/passenger-5.0.23/src/nginx_module
curi@curius:/opt/nginx/logs$ which ruby
/home/curi/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby
curi@curius:/opt/nginx/logs$ passenger-config --root
/home/curi/.rvm/gems/ree-1.8.7-2012.02/gems/passenger-5.0.23
curi@curius:/opt/nginx/logs$ ruby -v
ruby 1.8.7 (2013-06-27 MBARI 8/0x6770 on patchlevel 374) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2012.02
curi@curius:/opt/nginx/logs$ gem list passenger

*** LOCAL GEMS ***

passenger (5.0.23)
curi@curius:/opt/nginx/logs$ gem list rails

*** LOCAL GEMS ***

rails (2.3.18.14)
railslts-version (2.3.18.14)
curi@curius:/opt/nginx/logs$ uname -a
Linux curius 4.1.5-x86_64-linode61 #7 SMP Mon Aug 24 13:46:31 EDT 2015 x86_64 GNU/Linux
curi@curius:/opt/nginx/logs$ cat /etc/debian_version
8.2
curi@curius:/opt/nginx/logs$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.4.2
  - RUBY VERSION: 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/curi/.rvm/gems/ree-1.8.7-2012.02
  - RUBY EXECUTABLE: /home/curi/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby
  - EXECUTABLE DIRECTORY: /home/curi/.rvm/gems/ree-1.8.7-2012.02/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/curi/.rvm/gems/ree-1.8.7-2012.02
     - /home/curi/.rvm/gems/ree-1.8.7-2012.02@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
curi
  • 1
  • 3

1 Answers1

0

I found the answer. I needed to add a config.ru file to the root directory of my rails project:

https://blog.phusion.nl/2015/03/04/phusion-passenger-5-0-1-released/#rails_2_3

# Require your environment file to bootstrap Rails
require ::File.dirname(__FILE__) + '/config/environment'

# Serve static assets from RAILS_ROOT/public directory
# use Rails::Rack::Static
# Dispatch the request
run ActionController::Dispatcher.new
curi
  • 1
  • 3