Why question is not a duplicate
"Laravel daily log created with wrong permissions" question is starting from a different situation. I already have user member of www-data and already my processes are running as www-data and not creating file as root or as different group. So suggested solution is not enough.
Please, see my own answer to see the most simple solution to this common situation.
My storage/logs directory is configured as
drwxrwsr-x 2 user www-data 4096 Aug 21 14:39 logs
Note the sticky bit
Single log files are being created automatically as
-rw-r--r-- 1 www-data www-data 2381004 Aug 21 14:51 laravel-2019-08-21.log
Note, also, that my user
is a member of group www-data
.
The problem
accessing on ssh as user
, I cannot run php artisan queue:failed
because I got this error
UnexpectedValueException : The stream or file "/var/www/app/storage/logs/laravel-2019-08-21.log" could not be opened: failed to open stream: Permission denied
at /var/www/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
103| }
104| restore_error_handler();
105| if (!is_resource($this->stream)) {
106| $this->stream = null;
> 107| throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));
108| }
109| }
110|
111| if ($this->useLocking) {
Question
I cannot force server to create log file as user:www-data
But I need to be able to read and_write them. Or, at minimum, I need to able to run queue:*
commands
How should I fix this bad server config?
I'm using Debian 10.0