Php &引用;“流或文件”;laravel.log“;无法打开:无法打开流:权限被拒绝";

Php &引用;“流或文件”;laravel.log“;无法打开:无法打开流:权限被拒绝";,php,laravel-5,centos,Php,Laravel 5,Centos,几天前,我将文件上传到我的cent OS服务器上,它工作正常,但从今天起,我收到了错误 流或文件“/var/www/html/hasibtest/storage/logs/laravel.log” 无法打开:无法打开流:权限被拒绝 如果我的日志文件是777权限的,我也尝试使用07550644 有人能告诉我如何解决这个问题吗?首先尝试递归地获取目录的所有权 sudo chown -R $USER:www-data storage sudo chown -R $USER:www-data boots

几天前,我将文件上传到我的cent OS服务器上,它工作正常,但从今天起,我收到了错误

流或文件“/var/www/html/hasibtest/storage/logs/laravel.log” 无法打开:无法打开流:权限被拒绝

如果我的日志文件是777权限的,我也尝试使用07550644


有人能告诉我如何解决这个问题吗?

首先尝试递归地获取目录的所有权

sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
然后使用以下命令设置正确的目录访问权限

chmod -R 775 storage
chmod -R 775 bootstrap/cache

切勿将目录权限设置为777(除非您知道自己在做什么)

检查当前用户:
我在ubuntu上使用lampp,因此结果是
守护进程

然后运行几个命令,谢谢@Shobi

sudo chown -R daemon:www-data storage
sudo chown -R daemon:www-data bootstrap/cache

现在它可以工作了

尝试更改文件夹的所有者和文件夹的权限

sudo chown -R www-data storage/logs/
sudo chmod g+w -R storage/logs
现在应用子文件文件夹日志的所有规则

cd storage/logs
sudo find . -type d -exec chmod g+s '{}' +

请注意,您必须同时更改这两个选项。所有权和权限,以及这两个文件夹中的文件夹。 这应该影响到所有儿童

sudo chown -R apache storage
sudo chown -R apache bootstrap/cache

and

chmod -R 775 storage
chmod -R 775 bootstrap/cache

你可以查一下主人

ls -lr 

该命令将显示谁拥有所有权。

我找到的最短修复方法:

php artisan storage:link
sudo chown -R $USER:www-data storage bootstrap/cache
还是红帽

先做这个

 # sestatus
如果状态为启用,则必须禁用它

# setenforce Permissive
对我来说,组和用户是nginx so

chown -R nginx:nginx storage bootstrap/cache
chmod -R 775 storage
chmod -R 775 bootstrap/cache
这应该对你有帮助

chcon-R-t httpd\u系统内容\u t$SITE\u路径


chcon-R-t httpd\u sys\u rw\u content\u t$SITE\u PATH

最终,这是真正的解决方案,感谢我的使用案例,我不得不将www数据替换为“apache”