xampp ubuntu laravel 无法打开流或文件"/storage/logs/laravel log":无法打开流:权限被拒绝



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

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

如何解决?(我已经找到了答案,现在就发帖(

问题是运行 Apache 的用户无法访问该文件夹。 在 Ubuntu 上的 Xampp 中,主 Apache 进程的用户是 root 。 但是 Apache Worker 在daemon用户下运行。 解决方案是授予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"
     ]
}

然后运行作曲家安装或更新解决您的问题

最新更新