Closed bertalanimre closed 5 years ago
I expect this is not logger issue but server configuration. Logger also works when console command are running and then root user might be used. The solution might be using SQL_LOGGER_CONSOLE_SUFFIX
to create separate logs for HTTP and Artisan
Sounds like a plan. But I'm still wondering how can it be, that the files are created by root
, then web
tries to write it (the one running nginx and php).
If you are running cron or supervisor you might be running them as root and that's why files are created with root permissions and later when HTTP request is made using your web user it doesn't have enough rights to append to file created by root user
Oh yeah! That was the issue. One of my sys.operators wrote the cronjob and I didn't pay attention. He wrote it for the sudo user and not the web user. It was a job to run certain PHP commands. That is why the log file appeared with root permissions, but later on, the laravel application was unable to write it. Thanks for the help. :)
[2019-02-22 07:23:21] dev.ERROR: file_put_contents(/var/www/html/com.mywebsite/storage/logs/sql/2019-02-22-slow-log.sql): failed to open stream: Permission denied {"userId":40,"email":"a.user@somewhere.com","exception":"[object] (ErrorException(code: 0): file_put_contents(/var/www/html/com.mywebsite/storage/logs/sql/2019-02-22-slow-log.sql): failed to open stream: Permission denied at /var/www/html/com.mywebsite/vendor/mnabialek/laravel-sql-logger/src/SqlLogger.php:179)
I receive the following message in a laravel project. It tries to write to the folder, however it is unable to. I have CentOS 7 with NginX and PHP-FPM, both run by a user called
web
and all the folders and files haveweb:web
permissions. Interestingly a log file appeared but withroot:web
permissions. But web is not part of the sudoers obviously, it was made to serve as a webserver user. So then, how did a log file appear with root permissions?