我正在尝试使用 Thin 和 nginx 作为反向代理运行 Redmine。
我的 /etc/thin2.1/redmine.yml
:
---
pid: /var/run/thin/redmine.pid
group: redmine
wait: 30
timeout: 30
log: /var/log/thin/redmine.log
max_conns: 1024
require: []
environment: production
max_persistent_conns: 512
servers: 4
daemonize: true
user: redmine
socket: /var/run/thin/redmine.sock
chdir: /var/www/projects.mydomain.tld
当我使用 Web 浏览器访问该站点时,我得到一个
502 Bad Gateway
。这是 /var/log/thin/redmine.0.log
的内容:>> Writing PID to /var/run/thin/redmine.0.pid
>> Changing process privilege to redmine:redmine
>> Using rack adapter
>> Exiting!
/usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:158:in `delete': Permission denied @ unlink_internal - /var/run/thin/redmine.0.pid (Errno::EACCES)
from /usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:158:in `remove_pid_file'
from /usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:59:in `block in daemonize'
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/www/projects.mydomain.tld/config/boot.rb:4:in `<top (required)>'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/www/projects.mydomain.tld/config/application.rb:1:in `<top (required)>'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/www/projects.mydomain.tld/config/environment.rb:2:in `<top (required)>'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/www/projects.mydomain.tld/config.ru:3:in `block in <main>'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `instance_eval'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `initialize'
from /var/www/projects.mydomain.tld/config.ru:1:in `new'
from /var/www/projects.mydomain.tld/config.ru:1:in `<main>'
from /usr/lib/ruby/vendor_ruby/rack/adapter/loader.rb:36:in `eval'
from /usr/lib/ruby/vendor_ruby/rack/adapter/loader.rb:36:in `load'
from /usr/lib/ruby/vendor_ruby/rack/adapter/loader.rb:45:in `for'
from /usr/lib/ruby/vendor_ruby/thin/controllers/controller.rb:169:in `load_adapter'
from /usr/lib/ruby/vendor_ruby/thin/controllers/controller.rb:73:in `start'
from /usr/lib/ruby/vendor_ruby/thin/runner.rb:185:in `run_command'
from /usr/lib/ruby/vendor_ruby/thin/runner.rb:151:in `run!'
from /usr/bin/thin:6:in `<main>'
我不明白是什么导致了这个错误。
.pid
中的 /var/run/thin/
文件归 root 所有。我试图赋予 redmine
和 thin
所有权,但遇到了同样的错误(这些文件无论如何都会在重新启动 Thin 时重新创建)。我用rbenv安装了Ruby。我以 root 身份运行
bundle install
,这促使我这样做 will break this application for all non-root users on this machine
。根据 this answer 这应该不是问题,是吗?编辑: 如果我在
root
中将用户和组设置为 /etc/thin2.1/redmine.yml
,则权限被拒绝错误消失。我虽然它导致了另一个错误,但那个错误仍然存在。 最佳答案
对于 unlink
文件权限过程实际上需要写入该文件目录的权限。
因此,要么授予 redmine
编写 /var/run/thin/
的权限,要么将 pids 和 socket 放在其他地方——通常在应用程序的共享 tmp
中,rails 甚至为这些创建目录。
关于ruby-on-rails - 使用 Thin 运行的 Rails 应用程序 (Redmine) 中的权限被拒绝,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34495157/