我正在尝试在 Amazon Elastic Beanstalk 中上传 Lumen 项目。
.env 在 .gitignore 中。
没关系,因为我有几个环境(dev、qa、prod),所以我需要为每个环境配置单独的环境变量
我收到此错误消息:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Dotenv: Environment file .env not found or not readable. Create file with your environment settings at /var/app/current/bootstrap/../.env' in /var/app/current/vendor/vlucas/phpdotenv/src/Dotenv.php:33 Stack trace: #0 /var/app/current/bootstrap/app.php(4): Dotenv::load('/var/app/curren...') #1 /var/app/current/public/index.php(13): require('/var/app/curren...') #2 {main} thrown in /var/app/current/vendor/vlucas/phpdotenv/src/Dotenv.php on line 33
我了解系统找不到 .env
事情是我在 Amazon Console 中设置了变量:
Software Configuration
Environment variables: APP_ENV, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_HOST, APP_KEY
eb 打印环境:
Environment Variables:
DB_DATABASE = ebdb
DB_PASSWORD = xxxxxxxx
APP_KEY = xAY4hnrXlht5fdvB9PzPAwDqc1R
DB_HOST = xxxxxxcnzd3rux8ue7.us-east-1.rds.amazonaws.com:3306
APP_ENV = dev
DB_USERNAME = myuser
我也有 .ebextensions/environment.config :
container_commands:
# Copy EB env configuration file over
01_config_environment:
command: mv /var/app/ondeck/.env.elasticbeanstalk /var/app/ondeck/.env
02-install-packages:
command: "composer.phar install -d /var/app/ondeck/www"
option_settings:
option_name: DB_HOST
value: xxxxxxx.cnzd3rux8ue7.us-east-1.rds.amazonaws.com
- option_name: DB_PORT
value: 3306
- option_name: DB_NAME
value: ebdb
- option_name: DB_USER
value: myuser
- option_name: DB_PASS
value: xxxxxx
但是无法摆脱这个错误!