Разверните приложение Symfony в AWS с MySQL
У меня есть веб-приложение, работающее на AWS, а также экземпляр базы данных MySQL. Я настроил свою локальную среду для запуска приложения Symfony и подключения к экземпляру aws db. При попытке развернуть все было хорошо, пока я не добавил материал MySQL. Теперь, когда я внедряю, перехват установки composer завершается неудачно, и у меня остается следующий вывод:
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).
Интересно, что у меня даже нет файла composer.* В этом конкретном zip-файле, который я загрузил. Так что я немного озадачен тем, как он вообще так думает. Я думал, что моя проблема не в правильных значениях, установленных для моего соединения с БД. Тем не менее, я добавил переменные среды в конфигурацию среды со схемой именования SYMFONY__ENV__MYSQL__SERVER и т. Д.
Вот мой файл settings.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%
Любая помощь с благодарностью.
1 ответ
Проблема заключалась в том, что мой экземпляр веб-приложения не имел доступа (через группы безопасности) к моему экземпляру базы данных. Как я это исправил, было очень просто. Я удалил текущий экземпляр базы данных и создал новый из консоли веб-приложений -> Конфигурация -> Уровень данных. Затем я перестроил среду, и она, кажется, работает сейчас.