Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two files, one php file and one log file. The permission has been changed to the following:

-rwxr-x--- 1 www-data www-data  294 2012-06-25 10:17 function.php

-rwxr-x--- 1 www-data www-data    0 2012-06-25 09:53 log.txt

The permission is set to 750.

when I call function.php, I receive the following error message

fopen(log.txt): failed to open stream: Permission denied

This is the line :

$fp = fopen("log.txt","a");

I am very confused. I have php and the file to be written both under www-data now, so why would there be any permission problem?

Please help

share|improve this question
System log says...? – Ignacio Vazquez-Abrams Jun 25 '12 at 2:54

If you aren't on Windows, you can check if your process is really own by www-data by

$processUser = posix_getpwuid(posix_geteuid());
print $processUser['name'];

Check the directory too ! Are you sure that you are in the right dir ?

echo getcwd();
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.