3

我正在研究弹性豆茎扩展。每次部署都会发生存储权限被拒绝错误,我必须键入命令来解决该错误。下面的代码(.extensions/chmod.config)是否防止错误发生?

container_commands:
  01addpermission:
    command: "chmod -R 755 /var/app/current/storage"
  01clearcache:
    command: "php /var/app/current config:cache"
4

1 回答 1

3

遗憾的是,该代码不起作用。原因是容器命令在您的应用程序位于staging文件夹中时运行,而不是current文件夹中:

指定的命令以 root 用户身份运行,并按名称的字母顺序进行处理。容器命令从 staging 目录运行,您的源代码在部署到应用程序服务器之前被提取出来。

您可以尝试使用相对路径

container_commands:
  01addpermission:
    command: "chmod -R 755 ./storage"
  02clearcache:
    command: "php . config:cache"

一种方法是使用postdeploy平台钩子,它在部署应用程序后运行命令:

此处的文件在Elastic Beanstalk 平台引擎部署应用程序和代理服务器后运行

于 2020-07-29T09:12:07.063 回答