PHP Warning: Unknown: failed to open stream

Experienced the same error, for me it was caused because on my Mac I have changed the DocumentRoot to my users Sites directory.

To fix it, I ran the recursive command to ensure that the Apache service has read permissions.

sudo chmod -R 755 ~/Sites

If you are running Fedora, make sure SELinux is not interfering.You fix this with this command:

    sudo /sbin/restorecon -R /var/www/

More info here: linuxquestions.org/questions/linux-server-73/


I had the same error and my problem was the file permissions were incorrect.

chmod 755 index.php

worked for me.


It is a SELinux blocking issue, Linux prevented httpd access. Here is the solution:

# restorecon '/var/www/html/wiki/index.php'
# restorecon -R '/var/www/html/wiki/index.php'
# /sbin/restorecon '/var/www/html/wiki/index.php'