【发布时间】:2021-12-20 22:02:00
【问题描述】:
我正在尝试在 AWS Elastic Beanstalk 中为 php 启用 MongoDB ext 部署 Laravel 应用程序。
我在.ebextensions中有如下配置
文件:01_install_mongo.config
packages:
rpm:
php-pear: []
php-devel: []
gcc: []
files:
"/etc/php.d/99mongo.ini":
mode: "000755"
owner: root
group: root
content: |
extension=mongo.so
commands:
install_mongo_driver_command:
command: sudo pecl install mongodb
ignoreErrors: true
我什至尝试过command: sudo pecl install mongodb-1.10
文件:02_update_composer.config
commands:
01updateComposer:
command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update 2.1.11
option_settings:
- namespace: aws:elasticbeanstalk:application:environment
option_name: COMPOSER_HOME
value: /root
但是构建总是失败并出现以下错误:
> @php artisan package:discover --ansi
PHP Warning: PHP Startup: Unable to load dynamic library 'mongo.so' (tried: /usr/lib64/php/modules/mongo.so (/usr/lib64/php/modules/mongo.so: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/mongo.so.so (/usr/lib64/php/modules/mongo.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
知道可能是什么问题吗?
编辑
cfn-init.log
021-11-07 18:36:22,532 [INFO] -----------------------Starting build-----------------------
2021-11-07 18:36:22,539 [INFO] Running configSets: Infra-EmbeddedPreBuild
2021-11-07 18:36:22,542 [INFO] Running configSet Infra-EmbeddedPreBuild
2021-11-07 18:36:22,545 [INFO] Running config prebuild_0_test_app
2021-11-07 18:36:22,545 [INFO] All RPMs were already installed
2021-11-07 18:37:20,444 [INFO] Command install_mongo_driver_command succeeded
2021-11-07 18:37:20,449 [INFO] Running config prebuild_1_test_app
2021-11-07 18:37:23,357 [INFO] Command 01_update_composer succeeded
2021-11-07 18:37:23,361 [INFO] Running config prebuild_2_test_app
2021-11-07 18:37:23,363 [INFO] ConfigSets completed
2021-11-07 18:37:23,363 [INFO] -----------------------Build complete-----------------------
2021-11-07 18:42:59,394 [INFO] -----------------------Starting build-----------------------
2021-11-07 18:42:59,401 [INFO] Running configSets: Infra-EmbeddedPreBuild
2021-11-07 18:42:59,404 [INFO] Running configSet Infra-EmbeddedPreBuild
2021-11-07 18:42:59,407 [INFO] Running config prebuild_0_test_app
2021-11-07 18:42:59,407 [INFO] All RPMs were already installed
2021-11-07 18:42:59,773 [ERROR] Command install_mongo_driver_command (sudo pecl install mongodb) failed
2021-11-07 18:42:59,773 [INFO] ignoreErrors set to true, continuing build
2021-11-07 18:42:59,778 [INFO] Running config prebuild_1_test_app
2021-11-07 18:43:02,716 [INFO] Command 01updateComposer succeeded
2021-11-07 18:43:02,721 [INFO] Running config prebuild_2_test_app
2021-11-07 18:43:02,725 [INFO] ConfigSets completed
2021-11-07 18:43:02,726 [INFO] -----------------------Build complete-----------------------
2
在ignoreErrors: false 时,该命令会引发此异常。
Traceback (most recent call last):
File "/opt/aws/bin/cfn-init", line 176, in <module>
worklog.build(metadata, configSets)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 135, in build
Contractor(metadata).build(configSets, self)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 561, in build
self.run_config(config, worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 573, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 273, in build
self._config.commands)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
raise ToolError(u"Command %s failed" % name)
【问题讨论】:
-
尝试删除`命令中的sudo:sudo pecl install mongodb`
-
@N69S 对于您的第一条评论:我之前尝试过,失败了
-
@N69S 第二个,还是不行。
-
在mongo.ini的内容部分中extension=mongo.so不应该是extension=mongodb.so
标签: php laravel mongodb amazon-web-services amazon-elastic-beanstalk