Laravel & Docker: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
There are several options, what could be wrong:
- The
storage
link isn't properly set, you can read about it here, after launchingapp
container, you should dophp artisan storage:link
to check whether proper link is there - You don't have the proper right for the given folder, from default,
logs
folder should havewww-data
writable rights, you can check that by ssh to machine and the dols -l
on files in/var/www/html/[your laravel app]
, if not, add the proper rights by:chown -R www-data:www-data *
- Also related to file permissions: you can disable SELinux (but only in dev server, never do it on live) by cehcking the status:
sestatus
and then enforcing it to0
bysetenforce 0
(however on live server, it's better to leave SElinux running and try to disable the problem bychcon -R -t httpd_sys_rw_content_t [path to storage folder here]
if the above does not work when its added to your .env file the following will:
sudo chmod o+w ./storage/ -R
this will give others permissions without altering user and group permissions.
if you are using laravel sail, add following to your .env file
WWWGROUP=1000WWWUSER=1000