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

  • Actually, in the answer, the user is saying to never set 777 to this directory, and suggesting to change the directory ownership. – Laerte Jan 29 '18 at 16:58
  • So I did that and it wasn't helpful (as I mentioned in question) –  Jan 29 '18 at 17:06
  • 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) – ti7 Jan 29 '18 at 17:40
  • @ti7 I set permissions to root... –  Jan 29 '18 at 17:45
  • 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. – ti7 Jan 29 '18 at 17:52
  • @ti7 you wish I show laravel logs? (I hope I understood you correctly) –  Jan 29 '18 at 18:31

1 Answers1

34

This commands were helpful:

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