laravel - 通过 ebextentions 设置 laravel 存储目录权限

标签 laravel amazon-web-services amazon-elastic-beanstalk ebextensions laravel-artisan

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

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

最佳答案

遗憾的是,代码将无法运行。原因是 container commands当您的应用程序位于 staging 文件夹中时运行, current 文件夹中:

The specified commands run as the root user, and are processed in alphabetical order by name. Container commands are run from the staging directory, where your source code is extracted prior to being deployed to the application server.

你可以尝试使用相对路径:

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

替代方案是使用 postdeploy部署应用程序后运行命令的平台 Hook :

Files here run after the Elastic Beanstalk platform engine deploys the application and proxy server

关于laravel - 通过 ebextentions 设置 laravel 存储目录权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63150173/

相关文章:

ssl - 使用 SSL 的 Elastic Beanstalk 上的 Flask 给出 403 Forbidden

amazon-s3 - 从 CodeShip 部署到 Elastic Beanstalk 的适当 S3 权限是什么

php - 如何使用 laravel 中的干预图像处理库以自定义比例调整图像大小

php - 为什么 Laravel 或 Beanstalkd 会跳槽?

php - 为什么 created_at updated_at 在插入时为空

amazon-web-services - 你能通过 fargate 中的同一个容器将 desiredcount 缩小到 0 吗

node.js - 如何访问部署在aws elasticbeanstalk中的文件

php - Laravel:字段不插入

python - 在 EC2 实例中调用 plot 时为 "Unknown element o"

amazon-web-services - 在 Amazon Quicksight 中安排报告和数据驱动的警报