事实上,我是laravel的新手,我正在尝试创建我的第一个项目。出于某种原因,我一直得到这个错误(我甚至还没有开始编码)
Error in exception handler: The stream or file "/var/www/laravel/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/laravel/bootstrap/compiled.php:8423
我读到这与权限有关,但chmod -R 775存储根本没有帮助。
在Laravel中,您应该在存储和缓存目录上设置ACL,以便web服务器用户可以对该目录进行读写。打开一个新终端,运行如下命令:
HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1)
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX bootstrap/cache storage/
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX bootstrap/cache storage/
引用:
https://symfony.com/doc/3.4/setup/file_permissions.html#using-acl-on-a-system-that-supports-setfacl-linux-bsd
https://linux.die.net/man/1/setfacl