반응형
laravel server 운용중 아래와 같은 에러 발생
The stream or file "/var/www/html/{server-dir}/storage/logs/laravel-2023-07-11.log" could not be opened in append mode: failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file
로그 파일을 write 할 권한이 없다는 오류.
원인은 라라벨 스케쥴러를 crontab 으로 등록할 때 root user로 등록해서, root user가 생성한 log 파일을 서버 실행 유저 (nginx)가 접근하지 못하기 때문이었다.
해결방법: crontab으로 스케줄러를 등록할 때 root 사용자가 아닌 nginx로 등록한다.
$ sudo crontab -e -u nginx
** 또 다른 해결방법으로는
php_sapi_name()
위 코드를 사용해 php 인터페이스별(서버 api, sapi) 로깅을 분기처리하는 방법도 있다고 한다.
반응형
'개발 & IT > 백엔드' 카테고리의 다른 글
라라벨 Sail 설정 가이드 (2) | 2023.10.10 |
---|---|
[apache2] SPA(Single Page Application) 새로고침 시 404 error (0) | 2023.07.24 |
[php] version switch (2) | 2023.05.16 |
[PHP] version update (ubuntu) (1) | 2023.01.26 |
[JPA] native query 에서 @변수 사용 시 오류 (1) | 2023.01.10 |