fopen: failed to open stream: Permission denied on directory with 755

Posted on

fopen: failed to open stream: Permission denied on directory with 755 – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, apache-2.2, ubuntu, php, permissions.

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?


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

Solution :

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

Leave a Reply

Your email address will not be published. Required fields are marked *