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
來源:知乎
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。
