0

I want to use nginx as my Rails development server.I installed nginx and passenger.

My nginx configuration file is :

http{
      passenger_root /home/hxh/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.26;
      passenger_ruby /home/hxh/.rvm/wrappers/ruby-1.9.3-p448/ruby;
      include       mime.types;
      default_type  application/octet-stream;
      server {
        listen       80;
        server_name  localhost;
        root /home/hxh/share/ruby/sport;
        passenger_enabled on;
        rails_env development;
       }
}

But when I run the server,I got the error:

404 Not Found

nginx/1.4.4

why the nginx didn't identify the Rails page.

3
  • Is sport is your rails application root directory? Commented Dec 3, 2013 at 8:41
  • Yes,I can sure this.Because I have placed a html file in this directory,and I can visit this page in broswer. Commented Dec 3, 2013 at 8:48
  • Good, Try my below configuration, It's supposed to work. You was missing few configurations. Commented Dec 3, 2013 at 8:50

2 Answers 2

1

You need to point the root to the public folder, if /home/hxh/share/ruby/sport is indeed your project folder, then replace it with /home/hxh/share/ruby/sport/public

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks,I was careless.
1

Looks like you are missing couple of settings.

Try with below configuration, It supposed to work.

http {
  passenger_root /home/hxh/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.26;
  passenger_ruby /home/hxh/.rvm/wrappers/ruby-1.9.3-p448/ruby;
  include       mime.types;
  default_type  application/octet-stream;
  passenger_max_pool_size 10;
  access_log  off;
  sendfile        on;
  keepalive_timeout  65;
  gzip  on;


  server {
    listen       80;
    server_name  localhost;
    location / {
      root   /home/hxh/share/ruby/sport/public;
      passenger_enabled on;
      rails_env production;
    }
  }
}

Note:

  1. Your are missing location

  2. Your application root should point public folder

  3. Application root directory should have full execution permission

1 Comment

Thanks for your answer,the issue is my root should set to /home/hxh/share/ruby/sport/public.And after my test,the location isn't necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.