我正在研究弹性 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/