0

The stream or file "/var/www/maheshiya.com/public_html/storage/logs/laravel-2019-02-06.log" could not be opened: failed to open stream: Permission denied

enter image description here

How to fix this eror? Centos 7

  • Please don't post images of [code](http://idownvotedbecau.se/imageofcode) or [exceptions](http://idownvotedbecau.se/imageofanexception/) – Haem Feb 06 '19 at 12:15
  • Why do you share log files publicly? Seemes your application or web server does not have write access to that file. – Selaron Feb 06 '19 at 12:20
  • Check this https://stackoverflow.com/questions/24055056/laravel-log-could-not-be-opened-failed-to-open-stream – Saeed Vaziry Feb 06 '19 at 12:46
  • You have to change owner to apache user `www-data`. so it can perform the task. You can solve this simply running this command `chown -R www-data:www-data storage` – Kalyan Halder May 03 '20 at 11:59

1 Answers1

1

The proper solution is not to give every user on a server access to your storage directory or logs.

The proper solutions are either:

  1. Don't run artisan commands as other users so the log files aren't created/owned by another user. Run chown on the log files so the proper user owns it to correct this.

    chown -R user storage/logs

Or

  1. If you have some need for other users to run artisan commands, use a setgid bit and umask on the log directory so the group is constant and anyone a part of the group can write to the files in the directory. (More advanced)
Devon Bessemer
  • 34,461
  • 9
  • 69
  • 95