我尝试在带有Passenger / Apache的简单Sinatra应用程序中使用Resque,但每当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>'
答案 0 :(得分:0)
在这里找到解决方案: Troubleshooting "Permission denied" when attempting to connect to Redis from PHP script
SELinux要求您明确允许Apache进行套接字连接。
/usr/sbin/setsebool httpd_can_network_connect=1