在生产服务器上输入我的网站时出现以下错误:
无法打开流或文件“/var/app/current/storage/logs/laravel-2019-11-22.log”:无法打开流:权限被拒绝
我尝试运行以下命令,但 git 权限在终端中被拒绝:
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan optimize:clear
I ran chmod -R 775 storage/logs/
and 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/*
这在生产服务器上似乎是一个坏主意,但似乎是被赞成的答案。我应该只授予我的存储主管 777 权限吗?为什么?还有其他方法可以解决这个问题吗?
Edit:
我正在尝试按照此处所述执行此操作:
// 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'