I have setup Laravel homestead on a local OSX machine, everything seemed to be going smoothly until I tried to open example.app:8000 and got this error:
Error in exception handler: The stream or file "/home/vagrant/Code/example/app/storage/logs/laravel.log" could not be opened: failed to open stream: Protocol error in /home/vagrant/Code/example/bootstrap/compiled.php:8671
I followed the Laravel docs as well as a Laracast about setting up homestead, so I am not sure what would be causing this. I can see that /home/vagrant/Code/example/app/storage/logs/laravel.log
doesn't exist, but I assume that is something that should be created automatically?
All files and folders under app/storage
should be writable by you and group www-data (the webserver).
Error in exception handler: The stream or file "laravel/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in laravel/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:77
If you get this error (or a similar error) in the browser when accessing your site, then the group www-data
can't write to app/storage
. If you get this error when you execute certain php artisan
commands, then you (the user) can't write to app/storage
. Therefore both you and the www-data group must have write permission.
To ensure the files and folders have the correct permissions:
Go to the root of your Laravel installation (where composer.json
and artisan
live).
Change the owning user and group, where yourusername
is your username:
sudo chown -R yourusername:www-data app/storage
This recursively (-R
) sets the user:group owners to yourusername:www-data
in all files and folders from app/storage
onward.
Add the write permission for both you and the www-data
group:
sudo chmod -R ug+w app/storage
This recursively (-R
) adds (+
) the write flag (w
) to the user (u
) and group (g
) that own the files and folders from app/storage
onward.
Additionally, some suggest you may need to flush the application cache.
php artisan cache:clear
Finally, you may want to regenerate Composer's autoload files.
composer dump-autoload
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With