【问题标题】:Laravel application with Apache gives "use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'"带有 Apache 的 Laravel 应用程序提供“使用未定义的常量 MCRYPT_RIJNDAEL_128 - 假定为 'MCRYPT_RIJNDAEL_128'”
【发布时间】:2017-04-06 03:09:34
【问题描述】:

我对 Laravel 很陌生,我的问题始于运行我的应用程序阶段。出于某种原因,当我尝试在 http://127.0.0.1/test/public/ 访问我的应用程序时出现此错误(我有 Apache 服务器):

ErrorException in EncryptionServiceProvider.php line 16:
Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'
in EncryptionServiceProvider.php line 16
at HandleExceptions->handleError('8', 'Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'', '/srv/http/test/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php', '16', array('app' => object(Application))) in EncryptionServiceProvider.php line 16
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in Container.php line 773
at Container->build(object(Closure), array()) in Container.php line 656
at Container->make('encrypter', array()) in Application.php line 613
at Application->make('Illuminate\Contracts\Encryption\Encrypter') in Container.php line 887
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 848
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 813
at Container->build('Illuminate\Cookie\Middleware\EncryptCookies', array()) in Container.php line 656
at Container->make('Illuminate\Cookie\Middleware\EncryptCookies', array()) in Application.php line 613
at Application->make('Illuminate\Cookie\Middleware\EncryptCookies') in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 111
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53

我的系统上安装了 mcrypt:

[steelrat@archlinux test]$ php -m | grep mcrypt
mcrypt
[steelrat@archlinux test]$ php -i | grep mcrypt 
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

此外,当我使用 php artisan serve 启动 artisan web 服务器并使用 http://localhost:8000 访问它时,一切正常。这可能是什么问题?

我知道这个话题:Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'。但它看起来不像我的情况。我的问题是它适用于 artisan serve 而不适用于 apache。

【问题讨论】:

  • 最好不要使用mcrypt,它已经废弃了近十年了。因此,它已被弃用,并将在 PHP 7.2 中从核心中删除并进入 PECL。它不支持标准 PKCS#7 (née PKCS#5) 填充,仅支持甚至不能用于二进制数据的非标准空填充。 mcrypt 有许多出色的 bugs 可以追溯到 2003 年。请考虑使用 defuseRNCryptor,它们提供了完整的解决方案,正在维护并且是正确的。
  • zaph,感谢您的回答。如果我理解正确,它是 Laravel 的依赖项。我无意使用它。

标签: apache laravel mcrypt


【解决方案1】:

取决于您的系统,但对于 PHP CLI 和 PHP Apache,通常有单独的 php.ini

将以下内容添加到public/index.php的顶部

<?php phpinfo(); exit;

这将告诉您mod_php 知道哪些扩展以及您加载的php.ini 的位置

【讨论】:

    猜你喜欢
    • 2015-07-11
    • 2016-06-23
    • 2022-01-18
    • 2019-06-05
    • 2019-09-30
    • 2021-09-23
    • 2014-05-07
    • 2014-04-30
    • 2013-12-12
    相关资源
    最近更新 更多