疑难解答“权限被拒绝"尝试从 PHP 脚本连接到 Redis 时 [英] Troubleshooting "Permission denied" when attempting to connect to Redis from PHP script

查看:47
本文介绍了疑难解答“权限被拒绝"尝试从 PHP 脚本连接到 Redis 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器上打开了6379端口,我可以在SSH中成功运行telnet localhost 6379.

Port 6379 is open on the server, and I can successfully run telnet localhost 6379 in SSH.

我在 PHP 中尝试了 Predis/phpredis 客户端库,但它仍然不起作用:

I tried both Predis/phpredis client library in PHP, but it still does not work:

  • Predis 在打开 6379 的套接字时出现权限被拒绝"错误.
  • phpredis 给出redis 服务器消失了".

推荐答案

问题解决,输入:

/usr/sbin/setsebool httpd_can_network_connect=1

默认情况下,SELinux 不允许 Apache 进行套接字连接.可以在此处找到更多信息.

By default, SELinux does not allow Apache to make socket connections. More information can be found here.

这篇关于疑难解答“权限被拒绝"尝试从 PHP 脚本连接到 Redis 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆