0

I am working on Laravel 4. On remote server I took backup of old laravel.log and created new one and restored old one again by removing newly created one. Since then I am getting error:

Error in exception handler: The stream or file "/var/www/stage/webapp/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/staging_html/webapp/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:84

I even change mode and but it did not work either. It's not happening across system, just a particular page.

I am on Amazon AWS

Volatil3
  • 14,253
  • 38
  • 134
  • 263

1 Answers1

0

You recreated the file, so the permissions have changed, and apache can no longer access it. Run this in command line to set the permissions:

chown www-data:www-data /var/www/stage/webapp/app/storage/logs/laravel.log

That's if you're using apache. It changes ownership of the file to apache (web server). If the web server user isn't www-data. Find out by typing:

ls -l

In the command line to see what user owns the other files in your laravel directory. Replace www-data:www-data with the user that owns the other web files. To be clear the left side of the colon is user group and the right side is the user. If you have a specific user group that needs access to those files as well like git or ftp, you may need to set it like this:

git:www-data
ftp:www-data
group:user //generic example

It just depends on your access requirements. If you have questions let me know.

Evadecaptcha
  • 1,403
  • 11
  • 17
  • I wouldn't set ownership of this file to www-data. If the OP is running the app from cli too, that might break it. – baao Jul 31 '15 at 02:13
  • @Michael Thanks, I updated my answer. I was wondering about that, but wasn't sure how to convey that part of the answer at first. – Evadecaptcha Jul 31 '15 at 02:17
  • I deleted mine, yours will work for him I guess. To make it best, you should create a group containing all the users that might run the app and let the group own the application. http://stackoverflow.com/questions/27074370/set-user-permissions-artisan-command-will-not-run-in-code-but-works-fine-on-co/27074580#27074580 You're right with 777, not the best to do. – baao Jul 31 '15 at 02:21
  • Yeah. It's tough to have enough information for the answer without actually being on the server, that's why I almost went with chmod 777 myself, since it's the only thing that would work no matter the system specifics and user group requirements. – Evadecaptcha Jul 31 '15 at 02:22
  • I am on ubuntu and ubuntu usually use `www-data` as user. I will try once I get access to root. – Volatil3 Jul 31 '15 at 03:43
  • @RobertCathey chmod+777 did not work at all in this scenario. – Volatil3 Jul 31 '15 at 03:43
  • That's strange. If my answer doesn't work, run ls -l laravel.log to see what its permissions are and post them. – Evadecaptcha Jul 31 '15 at 03:44