xampp ubuntu laravel 无法打开流或文件“/storage/logs/laravel 日志”:无法打开流:权限被拒绝

xampp ubuntu laravel The stream or file "/storage/logs/laravel log" could not be opened: failed to open stream: Permission denied

在 ubuntu 上安装 laravel 我的 xampp 安装。在浏览器中打开它。收到错误:

The stream or file /storage/logs/laravel log could not be opened: failed to open stream: Permission denied

如何解决? (我已经找到答案了,马上 post)

问题是 apache 运行s 所在的用户无权访问该文件夹。在 ubuntu 上的 xampp 中,apache 主进程的用户是 root。但是 daemon 用户下的 apache 工作人员 运行。解决方案是授予 daemon 访问 /storage 目录的权限。 (如果你只授予 /storage/logs 而不是你会修复这个错误,但是同级目录也会发生同样的错误。因此 storage 本身文件夹:

sudo chown -R daemon /path-to-your-project/storage

现在 daemon 用户可以访问此文件夹(您没有,但您需要吗? 如果您有更好的解决方案,欢迎在这里分享!

添加到composer.json

    "scripts": {
    "post-install-cmd": [
          "chgrp -R www-data storage bootstrap/cache",
          "chmod -R ug+rwx storage bootstrap/cache"
     ]
}

然后 运行 composer install or update 解决你的问题