gpt4 book ai didi

ElasticBeanstalk 上的 Laravel 'log file permission denied' 错误不断出现,即使在 .ebextensions 配置文件中设置了权限

转载 作者:行者123 更新时间:2023-12-04 09:29:58 24 4
gpt4 key购买 nike

我正在将我的 Laravel 应用程序部署到 ElasticBeanstalk 环境。但我对 laravel.log 文件权限有疑问。

我使用“eb deploy”命令部署了我的应用程序。部署后,我访问我的应用程序。但它抛出以下错误。

The stream or file "/var/app/current/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

为了解决这个问题,我通过 ssh 进入服务器并运行以下命令。

sudo -u root chmod 777 -R /var/app/current/storage/logs

问题解决了。现在我的应用程序正在运行。但是我再次运行“be deploy”命令部署我的应用程序。部署后,问题再次弹出。以一致的方式解决问题。我尝试在 .ebextensions 配置文件中运行命令,如下所示。

container_commands:
01-migrations:
command: "php artisan migrate --force"
02-log-storage-permissions:
command: "sudo -u root chmod -R 777 /var/app/current/storage/logs/"

我可以部署我的应用程序。但问题仍然存在。该命令似乎不起作用。我的配置有什么问题,我该如何解决?

最佳答案

我认为这是因为 container_commands 在您的应用程序位于暂存文件夹中时运行。因此,在您运行 02-log-storage-permissions 之后,您的 /var/app/current 将被暂存文件夹替换。所以你的 chmod 不会持续存在。

要解决此问题,您可以尝试两个选项之一:

  1. 使用
  02-log-storage-permissions:
command: "sudo -u chmod -R 777 ./storage/logs/"

更改暂存文件夹中的日志。

  1. 使用postdeploy钩子(Hook)来运行你的脚本:

after the Elastic Beanstalk platform engine deploys the application and proxy server.

关于ElasticBeanstalk 上的 Laravel 'log file permission denied' 错误不断出现,即使在 .ebextensions 配置文件中设置了权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62885718/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com