gpt4 book ai didi

redis - Resque/Redis 的套接字权限问题

转载 作者:可可西里 更新时间:2023-11-01 10:59:06 24 4
gpt4 key购买 nike

我正尝试在一个简单的 Sinatra 应用程序中使用 Resque 和 Passenger/Apache,但每当 Resque 尝试访问 Redis 时都会出现权限错误。同样的错误会发生在各种方法中,包括 Resque.info 和 Resque.enqueue,并且无论 redis-server 是否实际运行都会发生

如果我在 irb 或 ruby​​ 脚本中编写相同的代码,它运行良好。

我试过切换同时运行 apache/passenger 和 redis 的用户,包括 root。

App 31099 stdout: 
App 31082 stderr: 2015-10-01 12:23:52 - Errno::EACCES - Permission denied - connect(2):
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:122:in `connect_nonblock'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:122:in `connect_addrinfo'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:162:in `block in connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `each'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `each_with_index'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:211:in `connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:322:in `establish_connection'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:94:in `block in connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:279:in `with_reconnect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:93:in `connect'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:350:in `ensure_connected'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:207:in `block in process'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:292:in `logging'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:206:in `process'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:112:in `call'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:1320:in `block in smembers'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:37:in `block in synchronize'
App 31082 stderr: /usr/share/ruby/monitor.rb:211:in `mon_synchronize'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:37:in `synchronize'
App 31082 stderr: /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:1319:in `smembers'
App 31082 stderr: /usr/local/share/gems/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:393:in `call_with_namespace'
App 31082 stderr: /usr/local/share/gems/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:290:in `method_missing'
App 31082 stderr: /usr/local/share/gems/gems/resque-1.25.2/lib/resque.rb:259:in `queues'
App 31082 stderr: /usr/local/share/gems/gems/resque-1.25.2/lib/resque.rb:431:in `info'
App 31082 stderr: /var/www/html/app.rb:29:in `block in <class:App>'

最佳答案

在这里找到了解决方案: Troubleshooting "Permission denied" when attempting to connect to Redis from PHP script

SELinux 要求您明确允许 Apache 建立套接字连接。

/usr/sbin/setsebool httpd_can_network_connect=1

关于redis - Resque/Redis 的套接字权限问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32894832/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com