This repository should help others how to deploy your Symfony application to AWS Elasticbeansstalk PHP instances.
- Elasticbeanstalk instance
- DB Instance
- Configured ENV Variables (configured via AWS UI)
APP_ENVDATABASE_URLMESSENGER_TRANSPORT_DSN(if messenger is used)MAILER_DSN(if mailer is used)
- Gitlab ENV Variables (if gitlab is used for deployment, configured via Gitlab UI)
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
- composer optimization (.ebextensions/composer.config)
- cronjob configuration (.ebextensions/cron-linux.config)
- doctrine migration configuration (.ebextensions/migration.config)
- php configuration (.ebextensions/php.config)
- redis extension included
- publicdir configuration (.ebextensions/publicdir.config)
- supervisor configuration (.ebextensions/supervisor.config)
- nginx vhost (.platform/nginx/conf.d/elasticbeanstalk/php.conf)
- gitlab deployment (.gitlab-ci.yml / .gitlab/create_aws_config.sh)
You did struggle with something let me know. So we can here add more faqs to help others avoiding same problems.
You can deploy when you have eb installed (MacOS brew install awsebcli) via:
eb init "Your Application Name" --platform "PHP 8.0 running on 64bit Amazon Linux 2" --region=eu-central-1 --profile=eb-cli
eb deployYou can use following command to debug deploy errors:
eb logsThe full logs you can download via the AWS Website. In my case following logs did help
eb-engine.logcfn-init.logcfn-init-cmd.log(this log file helped me find illegal syntax in mycommandscripts)
In the .platform/nginx/conf.d/elasticbeanstalk/nginx.conf it is possible to force https.
Via:
fastcgi_param HTTPS on;I could not get it work via x-forwarded-* headers as the were not send to my instance.
If your applicaton is running with multiple instances it is maybe important that your cronjobs only run on one instance for this have a look at the following issue and example:
#1.
If you have problem to deploy with supervisor and have following in your cfn-init-cmd.log:
/bin/sh: .ebextensions/supervisor/setup.sh: Permission deniedIt could be an error with the setup.sh not being executable so make it executable via:
chmod +x .ebextensions/supervisor/setup.sh: