Laravel.log permission issue
tcagkansokmen opened this issue · 3 comments
"var/app/current/storage/logs/laravel.log" could not be opened. failed to open stream: permission denied.
How can we solve this?
I added
13_permissions:
# fix permissions on the Laravel app folder
command: "chmod 777 -R /var/app/current/storage/logs/"
cwd: "/var/app/current/storage/logs/"
Line to deploy.config, but has no help.
This is a known issue with the file permissions. Before the traffic is routed to the new instances, it seems like AWS does something with the permissions of the /var/app/current folder. Currently, there is no way to fix it. 🤷 Any idea on how to fix it is highly appreciated.
For me this was happening because php artisan route:cache
was throwing an error due to duplicate route names. This command is run during the postdeploy
phase by the root account, so the error log ends up being created and owned by root. The fix in my case was to change the order of the postdeploy
scripts so that run_caches.sh
is run before make_folders_writable.sh
. This can be done by simply renaming the scripts to be prefixed with a number, and they will be run in ascending order.
Not sure if this is causing the issue for you, but it might help.