繁体   English   中英

即使在.ebextensions 配置文件中设置了权限,ElasticBeanstalk 上的 Laravel 的“日志文件权限被拒绝”错误也会不断出现

[英]Laravel on ElasticBeanstalk 'log file permission denied' error keeps coming up even the permission is set in the .ebextensions config file

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

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

我相信这是因为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 平台引擎部署应用程序和代理服务器之后。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM