【问题标题】:Laravel not working exception 'RuntimeException' with message 'No supported encrypter foundLaravel 不工作异常“RuntimeException”,消息“未找到支持的加密器”
【发布时间】:2016-04-07 20:51:21
【问题描述】:

我试图让我的 laravel 项目“上线”,但我失败了。我将从一开始就安装了一个 VPS,LAMP stackinstalled composerVSFTPD。去 /var/www/html 并做了一个git clone of my repo。将 apache 更改为指向正确的目录 chmoded the storage folder 最后在浏览器中访问我的服务器并受到 2 Whoops, looks like something went wrong 的欢迎。之后我决定检查storage/logs/laravel.log 并看到以下错误:

exception 'RuntimeException' with message 'No supported encrypter found. The cipher and / or key length are invalid.' in /var/www/html/laravel/bootstrap/cache/compiled.php:7658

并决定做一个php artisan key:generate 并得到这个输出Application key [base64:(key was here but removed it here for obvious reasons)] set successfully.。并再次检查并受到相同的 2 Whoops, looks like something went wrong 的欢迎。

现在我不知道该怎么做,非常感谢任何帮助。

【问题讨论】:

  • 你检查过here吗?

标签: php laravel encryption server


【解决方案1】:

您应该将 config/app.php 中的默认密码设置为“AES-256-CBC”。它需要一个 32 个字符的字符串,但默认键是“SomeRandomString”,它只有 16 个字符。

要么将密码更改为适用于 16 字符密钥的“AES-128-CBC”,要么为密钥生成一个新的 32 字符字符串。

在命令行上执行“php artisan key:generate”。这将为您生成正确的密钥。

更新:缓存编译存在问题,php artisan clear-compiled 修复了它。

【讨论】:

  • 你有你的 .env 文件吗?您可能有一个 .env.example 需要重命名为 .env 。通常,.env 文件在 repo 中被排除/忽略。
  • 是的,我在 git pull 后将 env 文件从本地机器上传到服务器。
  • 你的生产服务器上有 mcrypt 模块吗?
  • @EdericoRocha 是对的。造成这种情况的一个常见原因可能是缺少mcrypt PHP 模块。如果运行php -m | grep mcrypt 没有输出mcrypt 那么你需要安装它。如果您在生产服务器上运行基于 Debian 的系统,例如 Ubuntu,则安装模块就像运行 sudo apt-get install php5-mcrypt(或 sudo apt-get install php7.0-mcrypt,如果您运行的是 PHP 7)一样简单。
  • 好的,我的选项有点用完了。可能是你编译的缓存有问题,你能帮我做一个php artisan clear-compiled吗?
猜你喜欢
  • 2016-06-17
  • 1970-01-01
  • 2017-03-22
  • 1970-01-01
  • 1970-01-01
  • 2016-09-27
  • 2016-03-26
  • 1970-01-01
  • 2015-10-09
相关资源
最近更新 更多