If there is an error when running php artisan
command the log file will be created like this:
-rw-rw-r-- 1 user www-data 2,2K Jul 28 18:08 laravel-2019-07-28.log
If there is an error when using app through web browser the log file will be created like this:
-rw-r--r-- 1 www-data www-data 2,2K Jul 28 16:10 laravel-2019-07-28.log
After www-data has created the original file and if there is an error with php artisan
command,
it will throw an error Permission denied
because it can't write to the log
Is there a way to set default chmod for NEW created files, so that they always have rw
for group
Or you guys have some other solution for this
To reproduce this problem:
php artisan make:xy
-> this will make an error and create a .log fileWas struggling with this for a long time, and wondered the same thing as the OP, who asked:
Is there a way to set default chmod for NEW created files, so that they always have rw for group
The answer is YES.
In config/logging.php
I added permission => 0666
, which I found in the Laravel docs, so the config for my daily log now looks like this:
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'days' => 14,
'permission' => 0666,
],
Just to be clear, 0664
would already be enough to set group permission to rw
, but that still resulted in permission errors.
0666
has resolved the permission conflicts for me. Hope this helps someone!
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