ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

ruby-on-rails-连接到独角兽时,Nginx的权限被拒绝

2019-11-22 02:09:52  阅读:246  来源: 互联网

标签:nginx ruby-on-rails-3 ruby ruby-on-rails


我在网上尝试了许多建议,但没有任何效果.我有独角兽和nginx致力于在CentOS 6.5服务器上的Rails应用程序上部署Ruby.它以前曾经工作过,但现在当我尝试启动站点时遇到了错误的网关错误.我正在使用的两个主要文件是unicorn.rb配置文件和nginx的default.conf文件.这些文件的位置是:/home/myuser/myApp/config/unicorn.rb和/etc/nginx/conf.d/default.conf.它们包含以下内容:

独角兽

Set the working application directory
# working_directory "/path/to/your/app"
working_directory "/home/myuser/myApp"

# Unicorn PID file location
# pid "/path/to/pids/unicorn.pid"
pid "/home/myuser/myApp/pids/unicorn.pid"

# Path to logs
# stderr_path "/path/to/log/unicorn.log"
# stdout_path "/path/to/log/unicorn.log"
stderr_path "/home/myuser/myApp/log/unicorn.log"
stdout_path "/home/myuser/myApp/log/unicorn.log"

# Unicorn socket
# listen "/tmp/unicorn.[app name].sock"
listen "/home/myuser/myApp/tmp/unicorn.myApp.sock"

# Number of processes
# worker_processes 4
worker_processes 2

# Time-out
timeout 30

default.conf

upstream app {
        # Path to Unicorn SOCK file, as defined previously
        server unix:/home/myuser/myApp/tmp/unicorn.myApp.sock fail_timeout=0;
}

server {


    listen 80;
    server_name localhost;

    # Application root, as defined previously
    root /root/myApp/public;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}

我正在尝试从myuser运行这些东西,所以我不想移动unicorn文件或myApp.要进行此设置,我遵循了https://www.digitalocean.com/community/articles/how-to-deploy-rails-apps-using-unicorn-and-nginx-on-centos-6-5,但更改了某些步骤的目录.我知道在不更改目录的情况下该教程有效,但是我真的需要它在我的用户目录中运行.任何帮助表示赞赏.

看来问题出在nginx中.当查看nginx error.log时,我得到了:

2014/03/05 14:53:04 [crit] 5756#0: *1 stat() "/home/myuser/myApp/public/tasks/index.html" failed (13: Permission d$
2014/03/05 14:53:04 [crit] 5756#0: *1 stat() "/home/myuser/myApp/public/tasks" failed (13: Permission denied), cli$
2014/03/05 14:53:04 [crit] 5756#0: *1 connect() to unix:/home/myuser/myApp/tmp/unicorn.myApp.sock failed (13: Per$
2014/03/05 14:53:04 [crit] 5756#0: *1 stat() "/home/myuser/myApp/public/500.html/index.html" failed (13: Permissio$
2014/03/05 14:53:04 [crit] 5756#0: *1 stat() "/home/myuser/myApp/public/500.html" failed (13: Permission denied), $
2014/03/05 14:53:04 [crit] 5756#0: *1 connect() to unix:/home/myuser/myApp/tmp/unicorn.myApp.sock failed (13: Per$
2014/03/05 14:53:04 [crit] 5756#0: *1 stat() "/home/myuser/myApp/public/favicon.ico/index.html" failed (13: Permis$
2014/03/05 14:53:04 [crit] 5756#0: *1 stat() "/home/myuser/myApp/public/favicon.ico" failed (13: Permission denied$
2014/03/05 14:53:04 [crit] 5756#0: *1 connect() to unix:/home/myuser/myApp/tmp/unicorn.myApp.sock failed (13: Per$
2014/03/05 14:53:04 [crit] 5756#0: *1 stat() "/home/myuser/myApp/public/500.html/index.html" failed (13: Permissio$
2014/03/05 14:53:04 [crit] 5756#0: *1 stat() "/home/myuser/myApp/public/500.html" failed (13: Permission denied), $
2014/03/05 14:53:04 [crit] 5756#0: *1 connect() to unix:/home/myuser/myApp/tmp/unicorn.myApp.sock failed (13: Per$

我在网上找到的解决方案之一就是禁用SELinux.我尝试过,但没有帮助.这些文件的权限均为777,因此不应该发生这种情况.有任何想法吗?

解决方法:

我发现了问题. unicorn.myapp.sock的路径必须转到根目录下的/ tmp目录,而不是myuser目录中.另外,我的nginx default.conf文件中的根路径需要位于root / myApp / public而不是我的目录.我不知道最后一部分意味着什么,但是它起作用了,我很高兴.感谢所有帮助我到达这里的人.

标签:nginx,ruby-on-rails-3,ruby,ruby-on-rails
来源: https://codeday.me/bug/20191122/2056410.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有