好吧,我开始失去理智了。当我把我的应用程序部署到弹性豆茎上时,我得到了这个错误:
[2017-12-15 17:50:18] Tylercd100LERN.CRITICAL: RuntimeException was thrown! The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
要明确的是,我部署应用程序源时没有安装依赖项,也没有设置app_KEY,我将依赖项安装留给弹性beanstall,它在部署过程中安装它们。
在我的aws.config文件中,我定义了如下部署命令:
---
commands:
00init:
command: "sudo yum install gcc-c++"
01init:
command: "rm -f amazon-elasticache-cluster-client.so"
02init:
command: "wget https://s3.amazonaws.com/php-amazon-elasticache-cluster-client-7-1/amazon-elasticache-cluster-client.so"
03init:
command: "sudo mv amazon-elasticache-cluster-client.so /usr/lib64/php/7.1/modules/"
04init:
command: "echo "extension=amazon-elasticache-cluster-client.so" | sudo tee /etc/php-7.1.d/50-memcached.ini"
05init:
command: "sudo /etc/init.d/httpd restart"
container_commands:
00permissions:
command: "find * -type d -print0 | xargs -0 chmod 0755"
01permissions:
command: "find . -type f -print0 | xargs -0 chmod 0644"
02permissions:
command: "chmod -R 775 storage bootstrap/cache"
03cache:
command: "php artisan cache:clear"
04key:
command: "php artisan key:generate"
05cache:
command: "php artisan config:cache"
06cache:
command: "php artisan route:cache"
07optimize:
command: "php artisan optimize"
这些命令在部署到aws期间运行,没有任何错误。
当我直接在虚拟机上检查.env时,APP_KEY会根据上面的命令进行设置。
然而我得到了密码错误。
假设您在仪表板的elasticbeanstall配置页面中设置了APP_KEY
,我想指出两件事。
1-当php artisan config:cache
在container_commands
中运行时,它会将文件路径缓存为/var/app/ondeck/...
。这会在laravel尝试访问缓存的文件时导致运行时错误。
2-当laravel无法访问.env
文件中的APP_KEY
值时,会发生密码错误。如果.env
文件中存在类似APP_KEY=${APP_KEY}
的行,则这是导致错误的主要原因。您假设APP_KEY
值将从仪表板中的环境配置中读取。然而,当您的commands
或container_commands
正在运行时,豆茎还没有以某种方式设置环境变量。您可以通过在命令或文件中包含以下命令来自行解决我的源环境变量的问题。
source /opt/elasticbeanstalk/support/envvars
例如
"/opt/elasticbeanstalk/hooks/appdeploy/post/91_config_cache.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
source /opt/elasticbeanstalk/support/envvars
echo "Running php artisan config:cache"
cd /var/app/current
php artisan config:cache
echo "Finished php artisan config:cache"