Skip to content
Advertisement

PHP can open file only with 777 permissions

Have PHP script that log stuff. It’s job to open the file (*.txt), write to file and close it.

With 755 permissions on folder nothing works. I get a “Permission denied” error. With 777 permissions on folder, it’s working again. What the hell?

I’m using NGINX, ‘test’ is my user. Folders:

drwxr-xr-x  3 root root 4096 Feb 29 21:16 example.com
  drwxr-xr-x 4 test test 4096 Feb 29 21:57 html    
    -rw-r--r-- 1 test test 13286 Feb 29 22:04 log.txt
    -rw-r--r-- 1 test test  3517 Feb 29 21:57 request.php

Advertisement

Answer

PHP running under www-data user. After “chown” to that user, all is worked as it should

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement