Laravel项目出现"No supported encrypter found. The cipher and / or key length are invalid."的解决办法
在使用laravel5.2进行项目开发的时候,出现了“No supported encrypter found. The cipher and / or key length are invalid.”的报错信息,导致页面无法显示。
首先要看config/app.php
中的cipher
值。
如果cipher
的值是AES-256-CBC
,那么通过执行命令
php artisan key:generate
生成新的key
就可以解决。这时生成的新key
就会直接写入到.env
文件内。
如果cipher
是其他值,例如rijndael-256
,就需要安装和启动mcrypt
模块。AES-256-CBC
不需要的原因是因为AES-256-CBC
算法对应的底层是用openssl
实现的,而与mcrypt
无关。rijndael-256
则是依赖于mcrypt
模块。
1. 检查mcrypt
是否安装。
执行
php -r "print_r(mcrypt_list_algorithms());"
有无输出结果,或者查看
phpinfo()
2. 如果已经安装了就启动mcrypt
模块。
php5enmod mcrypt
3. 重启nginx
和php-fpm
评论啦~
暂无评论,快来抢沙发吧!