Nginx permission denied error for my Rails files?

问题内容:

I am trying to deploy a Rails app using nginx and Unicorn. After all the set up, I am trying to start the Unicorn and run it as a daemon using the configuration file config/unicorn.rb. However, I cannot since it points out that there are errors with nginx.
I proceed and check my nginx error logs and here is what I find using the command

tail -20 /var/log/nginx/error.log  


2017/12/11 02:20:22 [crit] 25638#0: *1 stat() "/var/www/mav/Rakefile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *1 stat() "/var/www/mav/config.ru" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *1 stat() "/var/www/mav/Gemfile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *1 stat() "/var/www/mav/Gemfile.lock" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *1 stat() "/var/www/mav/README" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *1 stat() "/var/www/mav/README.textile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *1 stat() "/var/www/mav/Rakefile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *1 stat() "/var/www/mav/config.ru" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *2 stat() "/var/www/mav/Gemfile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *2 stat() "/var/www/mav/Gemfile.lock" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *2 stat() "/var/www/mav/README" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *2 stat() "/var/www/mav/README.textile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *2 stat() "/var/www/mav/Rakefile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:22 [crit] 25638#0: *2 stat() "/var/www/mav/config.ru" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:23 [crit] 25638#0: *3 stat() "/var/www/mav/Gemfile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:23 [crit] 25638#0: *3 stat() "/var/www/mav/Gemfile.lock" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:23 [crit] 25638#0: *3 stat() "/var/www/mav/README" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:23 [crit] 25638#0: *3 stat() "/var/www/mav/README.textile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:23 [crit] 25638#0: *3 stat() "/var/www/mav/Rakefile" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"
2017/12/11 02:20:23 [crit] 25638#0: *3 stat() "/var/www/mav/config.ru" failed (13: Permission denied), client: 100.12.198.208, server: _, request: "GET / HTTP/1.1", host: "138.197.195.201"

What is wrong with my nginx conf ?

问题评论:

    
What are the permissions of your www folder?
    
drwxr-xr-x. 3 root root 43 Dec 10 01:09 www
– jungleMan
13 hours ago
    
you have to change permission for /var/www/mav/ dir using chmod

答案:

答案1:

You probably need to make all parent directories executable.

sudo chmod g+x,o+x /var/www/mav
sudo chmod g+x,o+x /var/www/
sudo chmod g+x,o+x /var

答案评论:

原文地址:

https://stackoverflow.com/questions/47745701/nginx-permission-denied-error-for-my-rails-files

添加评论