I have a problem.
I have a PHP script that does some actions and then create a .txt to put some logs into it.
When I run the script using my browser, it works perfectly, creates the txt file (one new is created each time the script is used), writes the logs into it ..
BUT
When I launch the script from the terminal using the command php, then I have the error:
Warning fopen […] failed to open stream: Permission denied
The permissions for the folder where I save the logs is 755. The folder is inside /Library/WebServer/Documents/
_www is the owner of the folder.
Thanks for your help.
Check that the directory / folder is accessible to everyone, and that the default file creating permissions of that directory / folder makes the file publicly accessible to the whole system, not just a single user. That sometimes stuffs it up.
If that doesn’t work, you could always try put
sudoin front of your command, followed by a space, so like this:$ sudo php whatever hereYou will then be prompted to type your user password.