Rock笔记
~/rocknotes/articles/278.md article
// article · laravel

Laravel 部署遇到文件权限不够无法写入日志的排查方法

在部署Laravel应用时,时常会遇到因权限问题无法写入日志而报错的情况

  1. Error in exception handler: The stream or file "/usr/site/laravel-app/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/laravel-app/bootstrap/compiled.php:8423

image.png


1.给storage和bootstrap/cache775权限

chown -R 775 storage
chown -R 775 bootstrap/cache


2.清一下缓存和包自动发现

php artisan package:discover
php artisan config:clear
php artisan cache:clear


3.当系统为centos 7.6,查看SELinux的模式是否开了强制模式。


SELinux 共有三种模式如下:

  • Enforcing:强制模式,依据设定来限制档案资源存取。

  • Permissive:宽容模式,不限制档案资源存取,但仍会依据设定检查并记录相关讯息。

  • Disabled:停用模式,SELinux 已被停用。

默认为强制模式。


查看SELinux状态

sestatus

image.png

可以看见当前为强制模式,现在需要改为宽容模式:

setenforce Permissive

再次查看状态,现已变更为宽容模式

image.png



参考:

https://dotblogs.com.tw/echo/2017/06/19/linux_selinux_mode

https://zh.wikipedia.org/wiki/%E5%AE%89%E5%85%A8%E5%A2%9E%E5%BC%BA%E5%BC%8FLinux

回复// 0 replies

最新回复 ↓
// 暂无回复

回复功能沿用原详情页:前往原页面参与讨论 →