Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am getting the error

fopen(/var/www/photos/testphoto.jpg): failed to open stream: Permission denied

when PHP is attempting to write a file to /var/www/photos, whose directory permissions are

drwxrwsr-x 3 root www-pub 4096 Oct 11 01:46 photos

I have already added apache2 user www-data to the group www-pub, why is it still unable to write files to the directory unless I chmod 777 /var/www/photos?


Update

As suggested by Laurentiu Roescu, I did a chmod 777 photos and let PHP write the file. Here's the output of ls -la

-rw-r--r--  1 www-data www-pub 34777 Oct 11 02:12 testphoto.jpg
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Do a chmod 777 on folder and create a file. Then please give the output of ls -la on that file.

share|improve this answer
    
Updated in original post –  Nyxynyx Oct 11 '12 at 6:14
    
Seems ok. Have you restarted apache after setting permissions to that folder? And you should also check selinux. –  Laurentiu Roescu Oct 11 '12 at 6:28
    
Somehow it works now, I guess I restarted Apache! :) –  Nyxynyx Oct 11 '12 at 7:18

Your Answer

 
discard

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.