将Laravel部署到Elastic Beanstalk时出现密码异常

问题描述 投票:1回答:1

好的,我开始在这里失去理智。当我将我的应用程序部署到弹性beanstalk时,我收到此错误:

[2017-12-15 17:50:18] Tylercd100\LERN.CRITICAL: RuntimeException was thrown! The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths. 

为了清楚我部署我的应用程序源没有安装依赖项并且没有设置APP_KEY,我将依赖安装留给弹性beanstalk,它在部署期间安装它们。

在我的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,因为它应该考虑上面的命令。

但我得到了密码错误。

laravel amazon-web-services laravel-5 amazon-ec2 elastic-beanstalk
1个回答
1
投票

假设您在仪表板的elasticbeanstalk配置页面中设置APP_KEY,我想指出两件事。

1-当php artisan config:cachecontainer_commands中运行时,它将文件路径缓存为/var/app/ondeck/...这会在laravel尝试访问缓存文件时导致运行时错误。

当laravel无法访问APP_KEY文件中的.env值时,会发生2-密码错误。如果你的APP_KEY=${APP_KEY}文件中存在像.env这样的行,那么这就是错误的主要原因。您假设将从仪表板中的环境配置中读取APP_KEY值。但是,当你的commandscontainer_commands正在运行时,beanstalk还没有设置环境变量。您可以通过在命令或文件中包含以下命令来自行解决此问题我的采购环境变量。

source /opt/elasticbeanstalk/support/envvars

EG

"/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"
© www.soinside.com 2019 - 2024. All rights reserved.