我正在将Laravel应用程序部署到ElasticBeanstalk。我正在部署时使用.ebextensions配置运行迁移命令。
我在项目根文件夹下创建了一个.extensions / 01-migration.config文件,内容如下。
container_commands:
01_cd_html:
command: "cd /var/www/html"
02_php_artisan_migrate:
command: "php artisan migrate --force"
然后,我通过运行以下命令来部署我的应用程序。
eb deploy
然后我遇到以下错误。
2020-07-13 11:51:59 INFO Environment update is starting.
2020-07-13 11:52:39 INFO Deploying new version to instance(s).
2020-07-13 11:52:49 ERROR [Instance: i-0a461ffb24bc26f52] Command failed on instance. An unexpected error has occurred [ErrorCode: 0000000001].
2020-07-13 11:52:49 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2020-07-13 11:52:49 ERROR Unsuccessful command execution on instance id(s) 'i-0a461ffb24bc26f52'. Aborting the operation.
2020-07-13 11:52:50 ERROR Failed to deploy application.
我可以通过SSH进入服务器并成功运行命令。但这只是无法进行部署。我的配置有什么问题,怎么解决?
答案 0 :(得分:0)
我解决了这个问题。我需要设置option_settings中的命令所需的环境变量。我尝试运行的命令是迁移命令,它正在使用数据库凭据。因此,我为数据库指定了env变量。太奇怪了,它应该只能与ElasticBeanstalk控制台中指定的功能一起使用。