问题描述
在 AWS elastic-beanstalk 解压缩我上传的压缩文件后,我需要使一些文件可执行。我需要 elastic-beanstalk 自动执行 chmod 才能使应用程序正常工作,例如:
sudo chmod 755 /var/www/html/mybin/executablefile1
sudo chmod 755 /var/www/html/mybin/executablefile2
如何正确执行此操作?
解决方法
您可以在 container_commands 的 .ebextensions 部分编写要执行的命令(包括 chmod):
容器命令在设置应用程序和 Web 服务器之后运行,并在提取应用程序版本存档之后,但在部署应用程序版本之前运行。
或者,您也可以使用 deployment platform hooks 之一。例如您在 postdeploy
中的自定义脚本:
此处的文件在 Elastic Beanstalk 平台引擎部署应用程序和代理服务器之后运行。这是最后的部署工作流程步骤。