Laravel The stream or file "/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
Asked Answered
H

1

12

I'm running Laravel app on server (Ubuntu 16.04). I have an error

The stream or file "/var/www/mydomain.com/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

I've already google my question. I found this answer, but it wasn't helpful. I can't set 777 permission for storage (it's dangerous), as was suggested by many other answers I found.
Any other suggestions?


UPDATE:

sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

was helpful

Homologate answered 29/1, 2018 at 16:50 Comment(6)
Actually, in the answer, the user is saying to never set 777 to this directory, and suggesting to change the directory ownership.Arabist
So I did that and it wasn't helpful (as I mentioned in question)Homologate
What did you set the permissions to? You likely want something like root:www 700 set for the logs directory (setting it for just the .log file may not be sufficient)Dunlap
@Dunlap I set permissions to root...Homologate
Sorry, it should obviously be 770 above; the group write permissions are required too. Please include at least the output of ls against the logs directory in your question to show its permissions and ownership.Dunlap
@Dunlap you wish I show laravel logs? (I hope I understood you correctly)Homologate
H
34

This commands were helpful:

sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
Homologate answered 5/2, 2018 at 6:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.