SELinux will cause this error on CentOS/RHEL 7+ by default :(
CentOS/RHEL 7+ 系统默认会因为SELinux出现这个报错
To test if SELinux is the source of your woes, do
你可以通过下面这个命令关闭SELinux,进行测试
setenforce 0
... and see if everything works. If that fixed it, you can leave SELinux off (weak, you‘re better than that), or you can turn it back on with
看看是否运行正常,如果成功修复了,你可以修改配置文件永久保留关闭,或者再打开SELinux
setenforce 1
... and then properly fix the issue.
然后妥善解决这个问题。
If you do
如果你执行
tail -f /var/log/audit/audit.log
... you‘ll see the SELinux issue. In my case, it was denying PHP-FPM access to web files. You can run the following directives to fix it:
你将会看到是SELinux的问题。在我看来,这是因为SELinux拒绝了PHP-FPM访问Web文件。您可以运行以下指令来修复它:
setsebool -P httpd_can_network_connect_db 1 setsebool -P httpd_can_network_connect 1
This actually didn‘t fix it for me at first, but then restoring SELinux context did it
这一步还没有完全修复好,继续执行下面命令修复上下文
restorecon -R -v /var/www(你的web目录)
Hope that helps.
希望能帮到你
作者:匿名用户
链接:https://www.zhihu.com/question/22128267/answer/105600681
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。