mysql - 使用 MySQL 将 Symfony 应用程序部署到 AWS

标签 mysql symfony amazon-web-services awsdeploy

我有一个在 AWS 上运行的 Web 应用程序以及一个 MySQL 数据库实例。我已经设置了本地环境来运行 symfony 应用程序并连接到 aws 数据库实例。当尝试部署时,一切都很好,直到我添加了 MySQL 的东西。现在,当我部署时,composer install hook 失败,我留下以下输出:

i-04b06d321dedd2a9c Severe  1 hour  8   -   -   -   -   -   -   -   -   -   -   0.00    0.01    0.1 0.0 99.9    0.0
Application deployment failed at 2016-06-22T13:51:22Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_composer_install.sh failed.

+ . /opt/elasticbeanstalk/support/envvars
++ export COMPOSER_HOME=/root
++ COMPOSER_HOME=/root
++ export PHP_MEMORY_LIMIT=256M
++ PHP_MEMORY_LIMIT=256M
++ export PHP_MAX_EXECUTION_TIME=60
++ PHP_MAX_EXECUTION_TIME=60
++ export PHP_DISPLAY_ERRORS=Off
++ PHP_DISPLAY_ERRORS=Off
++ export PHP_COMPOSER_OPTIONS=
++ PHP_COMPOSER_OPTIONS=
++ export PHP_ALLOW_URL_FOPEN=On
++ PHP_ALLOW_URL_FOPEN=On
++ export PHP_ZLIB_OUTPUT_COMPRESSION=Off
++ PHP_ZLIB_OUTPUT_COMPRESSION=Off
++ export PHP_DOCUMENT_ROOT=
++ PHP_DOCUMENT_ROOT=
++ export PHP_DATE_TIMEZONE=UTC
++ PHP_DATE_TIMEZONE=UTC
++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir
+ EB_APP_STAGING_DIR=/var/app/ondeck
+ cd /var/app/ondeck
+ '[' -f composer.json ']'
+ export COMPOSER_HOME=/root
+ COMPOSER_HOME=/root
+ '[' -d vendor ']'
++ /opt/elasticbeanstalk/bin/get-config optionsettings -n aws:elasticbeanstalk:container:php:phpini -o composer_options
+ PHP_COMPOSER_OPTIONS=
+ echo 'Found composer.json file. Attempting to install vendors.'
Found composer.json file. Attempting to install vendors.
+ composer.phar install --no-ansi --no-interaction
Running composer as root/super user is highly discouraged as packages, plugins and scripts cannot always be trusted
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
- Installing twig/twig (v1.24.1)
Loading from cache

- Installing symfony/polyfill-util (v1.2.0)
Loading from cache

- Installing paragonie/random_compat (v2.0.2)
Loading from cache

- Installing symfony/polyfill-php70 (v1.2.0)
Loading from cache

- Installing symfony/polyfill-php56 (v1.2.0)
Loading from cache

- Installing symfony/polyfill-mbstring (v1.2.0)
Loading from cache

- Installing symfony/symfony (v3.1.1)
Loading from cache

- Installing symfony/polyfill-intl-icu (v1.2.0)
Loading from cache

- Installing psr/log (1.0.0)
Loading from cache

- Installing psr/cache (1.0.0)
Loading from cache

- Installing doctrine/lexer (v1.0.1)
Loading from cache

- Installing doctrine/inflector (v1.1.0)
Loading from cache

- Installing doctrine/collections (v1.3.0)
Loading from cache

- Installing doctrine/cache (v1.6.0)
Loading from cache

- Installing doctrine/annotations (v1.2.7)
Loading from cache

- Installing doctrine/common (v2.6.1)
Loading from cache

- Installing bmatzner/fontawesome-bundle (4.6.1)
Loading from cache

- Installing jdorn/sql-formatter (v1.2.17)
Loading from cache

- Installing doctrine/doctrine-cache-bundle (1.3.0)
Loading from cache

- Installing doctrine/dbal (v2.5.4)
Loading from cache

- Installing doctrine/doctrine-bundle (1.6.3)
Loading from cache

- Installing doctrine/instantiator (1.0.5)
Loading from cache

- Installing doctrine/orm (v2.5.4)
Loading from cache

- Installing friendsofsymfony/user-bundle (dev-master 298f27c)
Cloning 298f27ce696deaa6ecd72e6ba563f892a17e0512

- Installing incenteev/composer-parameter-handler (v2.1.2)
Loading from cache

- Installing sensiolabs/security-checker (v3.0.2)
Loading from cache

- Installing sensio/distribution-bundle (v5.0.6)
Loading from cache

- Installing sensio/framework-extra-bundle (v3.0.16)
Loading from cache

- Installing kriswallsmith/assetic (v1.3.2)
Loading from cache

- Installing symfony/assetic-bundle (v2.8.0)
Loading from cache

- Installing monolog/monolog (1.19.0)
Loading from cache

- Installing symfony/monolog-bundle (2.11.1)
Loading from cache

- Installing symfony/polyfill-apcu (v1.2.0)
Loading from cache

- Installing swiftmailer/swiftmailer (v5.4.2)
Loading from cache

- Installing symfony/swiftmailer-bundle (v2.3.11)
Loading from cache

- Installing sensio/generator-bundle (v3.0.6)
Loading from cache

- Installing symfony/phpunit-bridge (v3.1.1)
Loading from cache

paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
doctrine/doctrine-cache-bundle suggests installing symfony/security-acl (For using this bundle to cache ACLs)
friendsofsymfony/user-bundle suggests installing willdurand/propel-typehintable-behavior (Needed when using the propel implementation)
sensio/framework-extra-bundle suggests installing symfony/psr-http-message-bridge (To use the PSR-7 converters)
kriswallsmith/assetic suggests installing leafo/lessphp (Assetic provides the integration with the lessphp LESS compiler)
kriswallsmith/assetic suggests installing leafo/scssphp (Assetic provides the integration with the scssphp SCSS compiler)
kriswallsmith/assetic suggests installing leafo/scssphp-compass (Assetic provides the integration with the SCSS compass plugin)
kriswallsmith/assetic suggests installing patchwork/jsqueeze (Assetic provides the integration with the JSqueeze JavaScript compressor)
kriswallsmith/assetic suggests installing ptachoire/cssembed (Assetic provides the integration with phpcssembed to embed data uris)
symfony/assetic-bundle suggests installing kriswallsmith/spork (to be able to dump assets in parallel)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
Generating autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache


[Doctrine\DBAL\Exception\ConnectionException] 
An exception occured in driver: SQLSTATE[HY000] [2002] Connection timed out 



[Doctrine\DBAL\Driver\PDOException] 
SQLSTATE[HY000] [2002] Connection timed out 



[PDOException] 
SQLSTATE[HY000] [2002] Connection timed out 


Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception


[RuntimeException] 
An error occurred when executing the "'cache:clear --no-warmup'" command: 

[Doctrine\DBAL\Exception\ConnectionException] 
An exception occured in driver: SQLSTATE[HY000] [2002] Connection timed out 


[Doctrine\DBAL\Driver\PDOException] 
SQLSTATE[HY000] [2002] Connection timed out 


[PDOException] 
SQLSTATE[HY000] [2002] Connection timed out 

. 


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] []...
Incorrect application version "app-b659-160621_222635" (deployment 8). Expected version "which-lineup-1" (deployment 13).

有趣的是,我上传的这个特定 zip 文件中甚至没有composer.* 文件。所以我有点困惑它是怎么想的。我认为我的问题是没有为我的数据库连接设置正确的值。但是,我使用命名方案 SYMFONY__ENV__MYSQL__SERVER 等将环境变量添加到我的环境配置中...

这是我的parameters.yml.dist 文件:

# This file is a "template" of what your parameters.yml file should look like
# Set parameters here that may be different on each deployment target of the app, e.g. development, staging, production.
# http://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
parameters:
    database_host:     %env.mysql.server%
    database_port:     %env.mysql.port%
    database_name:     %env.mysql.database%
    database_user:     %env.mysql.username%
    database_password: %env.mysql.password%

非常感谢任何帮助。

最佳答案

问题是我的 Web 应用程序实例无法(通过安全组)访问我的数据库实例。我如何修复它是非常基本的。我删除了当前的数据库实例,并从 Web 应用程序控制台 -> 配置 -> 数据层创建了一个新实例。然后我重建了环境,现在似乎可以工作了。

关于mysql - 使用 MySQL 将 Symfony 应用程序部署到 AWS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37970597/

相关文章:

sql - Mysql错误: #1247 - Reference 'karma' not supported (reference to group function)

symfony - 如何在服务/ Controller 之间共享 Symfony 中的 Redis 连接/RedisCache?

php - Doctrine ORM 异常

amazon-web-services - 从本地 Spark 访问 AWS Glue

amazon-web-services - 如何在 AWS Elastic Beanstalk 上安装音频波形程序

php - 如何使用动态创建的查询来搜索数据库?

php - 插入select语句,更改字段和逻辑思维

mysql - 多个连接的多个别名?

php - mb_convert_case 未定义函数(Symfony2 FOS/UserBundle)

php - 如何使用 PHP 调用亚马逊 MWS 订单?