nginx - Unable to open primary script

前端 未结 4 905
独厮守ぢ
独厮守ぢ 2020-12-31 00:22

I got error message:

FastCGI sent in stderr: \"Unable to open primary script: /home/messi/web/wordpress/index.php (No such file or directory)\" while reading r

4条回答
  •  天涯浪人
    2020-12-31 00:55

    SELinux will cause this error on CentOS/RHEL 7+ by default :(

    To test if SELinux is the source of your woes, do

    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

    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:

    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
    

    Hope that helps.

提交回复
热议问题