【问题标题】:Laravel on ElasticBeanstalk 'log file permission denied' error keeps coming up even the permission is set in the .ebextensions config file即使在 .ebextensions 配置文件中设置了权限,Laravel 在 ElasticBeanstalk 上的“日志文件权限被拒绝”错误也会不断出现
【发布时间】:2020-11-03 05:32:50
【问题描述】:

我正在将我的 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

问题解决了。现在我的应用程序正在运行。但是我再次运行“部署”命令部署我的应用程序。部署后,问题又出现了。以一致的方式解决问题。我尝试在 .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/"

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

【问题讨论】:

    标签: laravel amazon-elastic-beanstalk ebextensions


    【解决方案1】:

    我相信这是因为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 挂钩运行您的脚本:

    Elastic Beanstalk 平台引擎部署应用程序和代理服务器之后。

    【讨论】:

      猜你喜欢
      • 2018-03-08
      • 1970-01-01
      • 2019-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-11
      • 1970-01-01
      • 2015-08-02
      相关资源
      最近更新 更多