【问题标题】:Error to install composer on AWS Elastic Beanstalk在 AWS Elastic Beanstalk 上安装 composer 时出错
【发布时间】:2021-02-01 03:11:44
【问题描述】:

我正在尝试通过pipeline 将Laravel 应用程序部署到AWS EB,当我部署该应用程序时,当我检查日志文件的最后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!

我在.ebextensions 内有一个名为01_deploy.config 的文件,包含以下内容:

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

【问题讨论】:

  • "共享内存不足!" - 可能需要更多内存。您使用的是什么实例类型?
  • @Marcin 是 tc2.micro!但我没有选择它,它只是默认从EB创建的
  • 您可以尝试使用更大的实例。您可以在 EB 配置菜单中更改实例类型。
  • @Marcin 我把它改成了小实例,然后部署我得到了新的错误(更新的问题)
  • 你能检查一下`/var/log/cfn-init-cmd.log`,看看哪个命令失败了,为什么?

标签: laravel amazon-web-services amazon-elastic-beanstalk


【解决方案1】:

选项 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"

【讨论】:

    猜你喜欢
    • 2017-03-26
    • 2013-07-08
    • 2020-06-08
    • 2013-07-05
    • 2018-07-01
    • 2021-01-07
    • 2015-04-03
    • 2016-03-11
    • 2018-05-25
    相关资源
    最近更新 更多