php 使用未定义的常量 MCRYPT_RIJNDAEL_128 - 假设为 'MCRYPT_RIJNDAEL_128'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29993399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:42:05  来源:igfitidea点击:

Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'

phplaravellocalhostmcrypt

提问by Philip

I have successfully installed Laravel, but after running php artisan serveand going to localhost:8000I get this error:

我已成功安装Laravel,但运行后php artisan serve,并要localhost:8000我得到这个错误:

Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'

使用未定义的常量 MCRYPT_RIJNDAEL_128 - 假设为 'MCRYPT_RIJNDAEL_128'

I have checked phpinfo()on localhost:8888and it says that mcryptis properly installed. However the only thing I can think of is that maybe my path is wrong?

我已经检查phpinfo()localhost:8888,它说mcrypt安装正确。但是我唯一能想到的是,也许我的路径是错误的?

in my .bash_profileI have

在我.bash_profile我有

PATH=/usr/local/bin:$PATH

Every time I try to run Laravel commands I have to type this in the terminal:

每次我尝试运行 Laravel 命令时,我都必须在终端中输入:

export PATH="~/.composer/vendor/bin:$PATH" 

I am running on a Mac. Is there a simple way I can set up my bash_profileso that I can consistently change between localhost addresses and still have all the proper PHP functions working?

我在 Mac 上运行。有没有一种简单的方法可以设置我的bash_profile地址,以便我可以在本地主机地址之间持续更改,并且仍然可以使所有正确的 PHP 函数正常工作?

采纳答案by ZenithS

This problem relative to the PHP extensions loader. You no need to use laravel command at all after successful installation. Laravel framework need Mcrypt Library for the security module and encrypt some of configure file.

这个问题与 PHP 扩展加载器有关。安装成功后根本不需要使用 laravel 命令。Laravel 框架需要 Mcrypt 库作为安全模块并加密一些配置文件。

The things that you need is theses steps.

您需要的是这些步骤。

  1. Download Mcrypt http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
  1. 下载 Mcrypt http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download

then configure make and install it.

然后配置make并安装它。

  1. Download php http://php.net/releases/index.phpAbove 5.5.14 are suggested. (Use this path later on step 4)

  2. then download Autoconfigure

    curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
    tar xvfz autoconf-latest.tar.gz
    cd autoconf-2.69/
    ./configure
    make
    sudo make install
    
  3. then you have to go to directory level

    cd ***YOURPHPDIRECTORY***/ext/mcrypt/
    

    and run phpize within this directory level

    /usr/bin/phpize
    ./configure
    make
    sudo make install
    
  4. modify your php.ini to enable the mcrypt extension by insert this into php.ini

    extension=mcrypt.so
    
  5. Restart web server.
  1. 下载 php http://php.net/releases/index.php建议 5.5.14 以上。(稍后在步骤 4 中使用此路径)

  2. 然后下载自动配置

    curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
    tar xvfz autoconf-latest.tar.gz
    cd autoconf-2.69/
    ./configure
    make
    sudo make install
    
  3. 然后你必须去目录级别

    cd ***YOURPHPDIRECTORY***/ext/mcrypt/
    

    并在此目录级别内运行 phpize

    /usr/bin/phpize
    ./configure
    make
    sudo make install
    
  4. 通过将其插入 php.ini 来修改您的 php.ini 以启用 mcrypt 扩展

    extension=mcrypt.so
    
  5. 重新启动网络服务器。

回答by Eslam Mahmoud

More simple way on ubuntu

ubuntu 上更简单的方法

  • apt-get install php5-mcrypt
  • mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
  • php5enmod mcrypt
  • service apache2 restart
  • apt-get install php5-mcrypt
  • mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
  • php5enmod mcrypt
  • service apache2 restart

Note: if you don't have "/etc/php5/conf.d" just skip that step and it will work ok

注意:如果您没有“/etc/php5/conf.d”,请跳过该步骤,它会正常工作

check http://php.net/manual/en/mcrypt.installation.php

检查http://php.net/manual/en/mcrypt.installation.php

回答by Suyog Sawant

For Mac users's specially - install it using Home Brew

Mac 用户专用 - 使用Home Brew安装

I've installed an empty Laravel installation and got the following error message when navigating to http://localhost/kanban/public/:

我已经安装了一个空的 Laravel 安装,并在导航到http://localhost/kanban/public/时收到以下错误消息:

Notice: Use of undefined constant MCRYPT_RIJNDAEL_128 – assumed ‘MCRYPT_RIJNDAEL_128′ in /Library/WebServer/Documents/xxx/config/app.php on line 83

注意:使用未定义的常量 MCRYPT_RIJNDAEL_128 – 假设 'MCRYPT_RIJNDAEL_128' in /Library/WebServer/Documents/xxx/config/app.php on line 83

Googling for this error message return many tutorials on how to install mcrypt on Mac OS X (whether building it from source or using Homebrew). The problem was that both the mcrypt and the php55-mcrypt packages were properly installed:

谷歌搜索此错误消息会返回许多有关如何在 Mac OS X 上安装 mcrypt 的教程(无论是从源代码构建还是使用 Homebrew)。问题是 mcrypt 和 php55-mcrypt 包都已正确安装:

$ brew install mcrypt
Warning: mcrypt-2.6.8 already installed
$ brew install php55-mcrypt
Warning: php55-mcrypt-5.5.20 already installed

Mcrypt was also properly loaded by PHP:

Mcrypt 也被 PHP 正确加载:

$ php -m | grep mcrypt
mcrypt

$ php -i | grep mcrypt
Additional .ini files parsed => /usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini,
Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

for more details refer this link - http://benohead.com/mac-os-x-php-notice-use-undefined-constant-mcrypt_rijndael_128/

有关更多详细信息,请参阅此链接 - http://benohead.com/mac-os-x-php-notice-use-undefined-constant-mcrypt_rijndael_128/

回答by tven

If you are seeing this on ubuntu or other flavors of *nix , it might help to do the following:

如果您在 ubuntu 或其他版本的 *nix 上看到此内容,执行以下操作可能会有所帮助:

service php5-fpm restart

回答by BruceHill

I also had this problem in trying to deploy a Laravelto Apacheon Mac OS Sierra. I eventually found this postthat gave step-by-step instructions to resolve this issue. These instructions assume that you have Homebrewinstalled; if you don't have it installed, then paste the following into a Terminal window to install it:

我在尝试部署Laravelto Apacheon 时也遇到了这个问题Mac OS Sierra。我最终找到了这篇文章,其中提供了解决此问题的分步说明。这些说明假设您已安装Homebrew;如果您没有安装它,请将以下内容粘贴到终端窗口中进行安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Here is the relevant steps pasted from the post given above:

以下是从上面给出的帖子中粘贴的相关步骤:

Step 1: Install autoconf and mcrypt

第 1 步:安装 autoconf 和 mcrypt

I used homebrew to install autoconf and mcrypt, which is as easy as:

我用 homebrew 安装了 autoconf 和 mcrypt,这很简单:

brew install autoconf mcrypt

If this does not work for you, or you don't want to use homebrew, then check out this tutorial.

如果这对您不起作用,或者您不想使用自制软件,请查看本教程

Step 2: Build the PHP extension

第 2 步:构建 PHP 扩展

To build the PHP extension you will need the PHP 5.4.17 source code that is available for download hereand extract it:

要构建 PHP 扩展,您需要 PHP 5.4.17 源代码,可在此处下载并解压缩:

cd ~/Downloads
unzip PHP-5.4.17.zip

Then build the extension using the following commands:

然后使用以下命令构建扩展:

cd php-src-PHP-5.4.17/ext/mcrypt/
/usr/bin/phpize
./configure
make
sudo make install

Step 3: Enable the extension

第 3 步:启用扩展

All that is left is to enable the extension by editing /etc/php.ini. If this file is not present, copy /etc/php.ini.default and rename it:

剩下的就是通过编辑 /etc/php.ini 来启用扩展。如果此文件不存在,请复制 /etc/php.ini.default 并将其重命名:

sudo cp /etc/php.ini.default /etc/php.ini

Edit the /etc/php.ini file and add the following:

编辑 /etc/php.ini 文件并添加以下内容:

extension=mcrypt.so

Step 4: Restart apacheNow just restart apache and you're done!

第 4 步:重启 apache现在只需重启 apache 就大功告成了!

sudo apachectl restart

ADDITIONAL NOTES AND CLARIFICATION

附加说明和说明

I did encounter two issues with following these steps:

在执行以下步骤时,我确实遇到了两个问题:

  1. I had to match the PHPzip file that I downloaded to the version of PHP that was installed on my machine.
  1. 我必须将PHP下载的zip 文件与安装在我机器上的 PHP 版本相匹配。

So I did

所以我做了

php -v

to determine the version number and then changed the download to match that version number. In my case the PHPversion was 5.6.28 and so I needed to download the PHP source from

以确定版本号,然后更改下载以匹配该版本号。就我而言,PHP版本是 5.6.28,所以我需要从

https://github.com/php/php-src/archive/PHP-5.6.28.zip
  1. I got an exception at step 2 when I tried to do the sudo make install, the exception was caused by SIP, a security featured added by El Capitan. The exception is outlined in this question, and the resolution to this problem I found in this answer.
  1. 我在第2步中的异常,当我试图做的sudo make install,异常是由SIP引起的,安全有特色的加入El Capitan这个问题概述了这个例外,我在这个答案中找到了这个问题的解决方案

Applying the information from this answer changed the step 2 listed above and replaced the sudo make installwith the following:

应用此答案中的信息更改了上面列出的第 2 步,并将其替换sudo make install为以下内容:

mkdir -p /usr/local/lib/php/extensions
sudo make EXTENSION_DIR='/usr/local/lib/php/extensions' install

Take note that because of this change, step 4 above also needs to changed to include the path to mcrypt.so. So the following must go in the php.ini:

请注意,由于此更改,上面的第 4 步也需要更改以包含mcrypt.so. 所以以下必须在php.ini

extension=/usr/local/lib/php/extensions/mcrypt.so

回答by WoodyDRN

I use nginx and php-fpm, and already did apt-get install php5-mcrypt, and moved the mcrypt.inifile to mods-available.

我使用 nginx 和 php-fpm,并且已经做了apt-get install php5-mcrypt,并将mcrypt.ini文件移动到mods-available.

I had to do sudo service php5-fpm restartbefore it actually worked.

sudo service php5-fpm restart在它真正起作用之前我必须这样做。

回答by jonasantonelli

I just adjusted the .bash_profilein MacOS and it worked:

我刚刚.bash_profile在 MacOS 中调整了它,它起作用了:

export PATH="/usr/local/sbin:$PATH"
PHP_AUTOCONF="/usr/local/bin/autoconf"
source ~/.bash_aliases