Troubleshoot: Setting up rails project with nginx + passenger locally (on a mac)

Problem: I installed nginx + passenger on my local computer, but I can't connect my rails project to nginx. Here's what I did:

  • I've installed nginx + passenger using brew, as instructed here: https://www.phusionpassenger.com/library/install/nginx/install/oss/osx/

  • I edited the config file (under /usr/local/etc/nginx/nginx.conf) to the following:

    http {
        passenger_root /usr/local/opt/passenger/libexec/lib/phusion_passenger/locations.ini;
        passenger_ruby /usr/bin/ruby;
        ...
    
        server {
            listen 3000;
            server_name localhost;
            rails_env development;
            root /absolute/path/to/rails/project/public
            passenger_enabled on;
        }
    
        location / {
            root html;
            index index.html index.htm;
        }
    
        ...
    }
    
  • Then I start nginx by typing "nginx" in terminal

  • Now when I go to localhost:3000, all I get is the default "Welcome to nginx!" page. What I expect to see is my home root page.

  • Questions
    - What am I doing wrong? aka, why is the rails project not showing?
    - Any recommendations for troubleshooting?

    Note
    - localhost:3000 works if I'm run "rails server" (webrick)
    - Running Rails 3.2.19, ruby 2.1.4, nginx 1.8, Phusion Passenger 5.0.18.

    Thank you.


    This is likely to be an Nginx issue. I recommend that you use Passenger Standalone so that you don't have to deal with Nginx. It's much easier. Just run 'passenger start' in your application directory.

    链接地址: http://www.djcxy.com/p/5562.html

    上一篇: 如何使用Nginx在乘客中运行Sinatra应用程序?

    下一篇: 疑难解答:使用nginx + passenger在本地设置rails项目(在Mac上)