I have setup laravel on a linux server and my apache is owned by root and www is owned by www-data and any new file created is owned by root user in the storage dir here is the screenshot of permissions for all directories inside /var/www/website/

And these are the permissions inside storage/logs dir. The newly created file is owned by the root user. Now, web server is unable to open this file for writing which causes errors on the website. I am not sure if this happens whent the root owns the file or when. But I kept ignoring this and kept applying a temporary fix by using the commands

sudo chmod -R 775 storage or sudo chown www-data:www-data storage

I want to fix this error once and for all. For reference these are the permissions inside /etc/ dir


ACL let's you add additional user permissions - where for example, the file could be owned by www-data but other users can have r/w permission on it. To set this up:

Install acl (apt install acl). Then in your fstab file, add acl as an option. For example:

/dev/sda / ext3 noatime,errors=remount-ro,acl 0 1

Then remount:

mount -a

Change the ownership of all the files backed to www-data if you've changed them. Set the default "acls" for any files that will later be created:

setfacl -dm u:myname:rwx /var/www

... and set the acls on already existing files:

setfacl -m u:myname:rw

... and directories

setfacl -m u:myname:rwx
  • adding user root to the www-data group wont solve the problem? – Chaudhry Waqas Dec 23 '18 at 13:37
  • root can already change any file so adding root to another group won't help. But you can setfacl -m u:www-data:rw on those files - and change the default acl on the log directory so www-data can access the new log files. – Eric Mintz Dec 23 '18 at 13:41
  • yeah, but in my case as you can see the log file owned by root doesnt have appropriate permissions prntscr.com/lym6lp – Chaudhry Waqas Dec 23 '18 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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