Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'

两盒软妹~` 提交于 2019-11-29 04:04:38

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.

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

then configure make and install it.

  1. Download php http://php.net/releases/index.php Above 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.
Eslam Mahmoud

More simple way on ubuntu

  • 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

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

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

I’ve installed an empty Laravel installation and got the following error message when navigating to 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

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:

$ 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:

$ 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/

tven

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

service php5-fpm restart

I just adjusted the .bash_profile in MacOS and it worked:

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

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

/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

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

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

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

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

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:

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

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

extension=mcrypt.so

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

sudo apachectl restart

ADDITIONAL NOTES AND CLARIFICATION

I did encounter two issues with following these steps:

  1. I had to match the PHP zip file that I downloaded to the version of PHP that was installed on my machine.

So I did

php -v

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

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.

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

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:

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

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!