laravel - 在 AWS Elastic Beanstalk 上安装 composer 时出错
问题描述
我正在尝试将应用程序部署Laravel
到AWS EB
通过pipeline
部署应用程序时,当我检查日志文件的最后 100 行时,在最近的事件中出现错误,我发现了这个错误:
2020/10/18 00:43:08.443797 [INFO] Executing instruction: Install composer dependencies
2020/10/18 00:43:08.443819 [INFO] installing composer dependencies...
2020/10/18 00:43:08.443859 [INFO] Running command /bin/sh -c composer.phar install --no-ansi --no-interaction
2020/10/18 00:43:08.482582 [ERROR] An error occurred during execution of command [app-deploy] - [Install composer dependencies].
Stop running the command. Error: installing composer dependencies failed with error: Command /bin/sh -c composer.phar install --no-ansi --no-interaction failed with error exit status 254. Stderr:Sun Oct 18 00:43:08 2020 (12045):
Fatal Error Insufficient shared memory!
我有一个文件01_deploy.config
在里面.ebextensions
调用:
option_settings:
# Point the app root to the public/ folder.
- namespace: aws:elasticbeanstalk:container:php:phpini
option_name: document_root
value: /public
# Set here your php.ini `memory_limit` value.
- namespace: aws:elasticbeanstalk:container:php:phpini
option_name: memory_limit
value: 256M
container_commands:
01_install_composer_dependencies:
command: "sudo php /usr/bin/composer.phar install --no-dev --no-interaction --prefer-dist --optimize-autoloader"
cwd: "/var/app/current"
02_install_node_dependencies:
command: "sudo npm install"
cwd: "/var/app/current"
05_run_migrations:
command: "php artisan migrate --force"
cwd: "/var/app/current"
leader_only: true
编辑:
2020/10/18 10:28:58.643232 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:us-east-2:129692188551:stack/awseb-e-ptmhtrxjzh-stack/af3b2a70-0ce0-11eb-8981-0618bcd9a382 -r AWSEBAutoScalingGroup --region us-east-2 --configsets Infra-EmbeddedPostBuild
2020/10/18 10:29:45.306985 [ERROR] An error occurred during execution of command [app-deploy] - [PostBuildEbExtension].
Stop running the command. Error: Container commands build failed. Please refer to /var/log/cfn-init.log for more details.
Edit2:最后一个错误
2020-10-18 10:39:44,791 [ERROR] Unhandled exception during build: Command 05_run_migrations failed
Traceback (most recent call last):
File "/opt/aws/bin/cfn-init", line 171, in <module>
worklog.build(metadata, configSets)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 129, in build
Contractor(metadata).build(configSets, self)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 530, in build
self.run_config(config, worklog)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
changes['commands'] = CommandTool().apply(self._config.commands)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
raise ToolError(u"Command %s failed" % name)
ToolError: Command 05_run_migrations failed
解决方案
选项 1:您可以在本地安装 composer 并将供应商文件夹包含在 zip 存档中,同时将其发送到 Elastic Beanstalk
选项 2:使用此 container_command
command: "sudo php -d memory_limit=-1 /usr/bin/composer.phar install --no-dev --no-interaction --prefer-dist --optimize-autoloader"
推荐阅读
- javascript - 一个功能由两个按钮激活
- excel - 将变量声明为 Arena.Application 会生成编译错误:未定义用户定义的类型
- python - 将 tflearn 模型转换为 keras
- java - PdfPTable 中的列
- python - python是否有一个reduce函数,我们可以在其中访问当前项目的索引?
- rust - 如何从派生的 NetworkBehaviour 发出 SwarmEvent::Behaviour?
- debian - Debian libsll 冲突
- python - 多行字符串 Python 正则表达式
- sqlite - Cloud Run:为什么我的实例需要这么多 RAM?
- java - 具体列表类型作为java方法中的参数