在生产服务器上进入网站时,出现以下错误:
流或文件“ /var/app/current/storage/logs/laravel-2019-11-22.log”无法打开:打开流失败:权限被拒绝
我尝试运行以下命令,并在终端中拒绝了Permisions:
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan optimize:clear
我跑了chmod -R 775 storage/logs/
,composer dump-autoload
能够顺利进入我网站的首页。在网站上浏览了一些之后,我在各个地方都遇到了相同的错误,而在其他地方却没有:
同样的错误
流或文件“ /var/app/current/storage/logs/laravel-2019-11-22.log”无法打开:打开流失败:权限被拒绝
我删除了以下文件并运行php artisan cahce:clear
:
/bootstrap/cache/packages.php
/bootstrap/cache/services.php
/bootstrap/cache/config.php.php
我看到的唯一其他建议是运行:
sudo chmod -R 777 storage/*
在生产服务器上,这似乎是一个坏主意,但似乎已被拒绝。我应该只给我的Storage Director 777权限,为什么?还有另一种解决方法吗?
编辑:
我正在尝试这样做,如下所示:
// set current user as owner and the webserver user as the group
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
// set directory permission to be 775
chmod -R 775 storage
chmod -R 775 bootstrap/cache
但是当我运行时出现sudo chown -R $USER:www-data storage
此错误:
chown:无效的组:'myusername:www-data'
好吧,我得到了答案:
AWS AMIwebapp
用作Web用户,而不是apache或ec2-user
文件显示的用户。在这种情况下,webapp
用户对这些文件没有访问权限。
sudo chown $USER:webapp ./storage -R
find ./storage -type d -exec chmod 775 {} \;
find ./storage -type f -exec chmod 664 {} \;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句