在mac php7.2 MAMP

时间:2018-06-04 04:31:34

标签: terminal phpmyadmin mamp mcrypt

我尝试了关于堆栈溢出的大部分教程,但没有成功。

Issue in installing php7.2-mcrypt

https://github.com/tamtamnl/valet-plus/tree/hotfix/homebrew-core-php

https://github.com/weprovide/valet-plus/issues/127

https://github.com/Homebrew/homebrew-core/issues/26082

Enable MCrypt using MAMP

Laravel requires the Mcrypt PHP extension

Error 1 : Check Image Here

Here's my PHP Version on MAMP

以下是我在终端

上查看版本时的内容

ArnieVelozasMBP:~ ArnieVeloza$ php -v
PHP 5.6.33 (cli) (built: Feb  1 2018 13:59:05) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans
ArnieVelozasMBP:~ ArnieVeloza$

当我尝试在终端上安装mcrypt时,这就是我得到的

ArnieVelozasMBP:~ ArnieVeloza$  sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo: apt-get: command not found

我尝试了以下步骤

brew install mcrypt

这是我得到的

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
youtube-dl

Warning: mcrypt 2.6.8 is already installed and up-to-date
To reinstall 2.6.8, run `brew reinstall mcrypt`

Arnie-Velozas-Macbook-Pro:~ ArnieVeloza$ brew reinstall mcrypt
==> Reinstalling mcrypt 
==> Downloading https://homebrew.bintray.com/bottles/mcrypt-2.6.8.yosemite.bottl
Already downloaded: /Users/ArnieVeloza/Library/Caches/Homebrew/mcrypt-2.6.8.yosemite.bottle.1.tar.gz
==> Pouring mcrypt-2.6.8.yosemite.bottle.1.tar.gz
  /usr/local/Cellar/mcrypt/2.6.8: 18 files, 396.7KB
Arnie-Velozas-Macbook-Pro:~ ArnieVeloza$ 

然后,我检查是否安装了mcrypt

brew search mcrypt

这是我得到的

Arnie-Velozas-Macbook-Pro:~ ArnieVeloza$ brew search mcrypt
==> Searching local taps...

mcrypt ✔                                            libtomcrypt
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...

通过终端安装mcrypt成功后,我将mcrypt.so扩展名添加到php.ini。

/Applications/MAMP/bin/php/php7.2.1/conf/php.ini

extension=mcrypt.so

我验证了扩展程序是否已安装,我得到了这个;

Arnie-Velozas-Macbook-Pro:~ ArnieVeloza$ php -i | grep "mcrypt"
Configure Command =>  './configure'  '--prefix=/usr/local/php5' '--with-apxs2=/usr/sbin/apxs' '--with-config-file-scan-dir=/usr/local/php5/php.d' '--with-libxml-dir=shared,/usr' '--with-openssl=/usr/local/php5' '--with-zlib=/usr' '--with-zlib-dir=/usr' '--with-gd' '--with-ldap' '--with-xmlrpc' '--enable-exif' '--enable-soap' '--enable-wddx' '--enable-ftp' '--with-iodbc' '--enable-sockets' '--with-bz2=/usr' '--enable-zip' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-mbstring' '--enable-bcmath' '--enable-calendar' '--with-mhash' '--enable-fpm' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pcntl' '--enable-dtrace' '--enable-opcache' '--with-icu-dir=/usr/local/php5' '--with-mssql=shared,/usr/local/php5' '--with-pdo-dblib=shared,/usr/local/php5' '--with-xsl=shared,/usr/local/php5' '--with-imap=shared,../imap-2007f' '--with-kerberos=/usr' '--with-imap-ssl=/usr/local/php5' '--with-gettext=/usr/local/php5' '--with-curl=shared,/usr/local/php5' '--with-png-dir=/usr/local/php5' '--with-jpeg-dir=/usr/local/php5' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local/php5' '--with-pgsql=shared,/usr/local/php5' '--with-pdo-pgsql=shared,/usr/local/php5' '--with-mcrypt=shared,/usr/local/php5' '--with-tidy=/usr/local/php5' '--with-gmp=shared,/usr/local/php5' '--with-readline=shared,/usr/local/php5' '--with-libxml-dir=/usr/local/php5' 'CC=cc '-L/usr/local/php5/lib' '-I/usr/local/php5/include' '-I/usr/include/libxml2' '-I/usr/local/php5/include/tidy' '-DENTROPY_CH_RELEASE=1'' 'CFLAGS=-Os '-mmacosx-version-min=10.10' '-I/usr/local/php5/include' '-arch' '-no-cpp-precomp' '-DENTROPY_CH_ARCHS='''i386/x86_64'''' '-DENTROPY_CH_RELEASE=1'' 'LDFLAGS=-L/usr/local/php5/lib '-arch' 'CXXFLAGS=-arch
/usr/local/php5/php.d/50-extension-mcrypt.ini,
Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*, http.*
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
Arnie-Velozas-Macbook-Pro:~ ArnieVeloza$ 

重新启动系统,运行我的php系统时仍然出现此错误

An Error Was Encountered
The Encrypt library requires the Mcrypt extension.

请帮帮我。提前致谢!

1 个答案:

答案 0 :(得分:0)

如果您没有正确安装mcrypt库,请尝试以下操作:

https://gist.github.com/idleberg/24479f34dc5007e50d47

或参见http://www.php.net/manual/en/mcrypt.setup.php了解其他信息。

如果您使用共享主机,则可以要求您的提供商进行安装。


在OSX本地主机中,您可以通过自制程序轻松地安装mcrypt-如上文所述:

brew install mcrypt

然后将这一行添加到您的php.ini文件中。 您可以从上面的自制程序输出中看到:“ /usr/local/Cellar/mcrypt/2.6.8”

extension="/usr/local/Cellar/mcrypt/2.6.8/mcrypt.so"

别忘了重新启动服务器以使编辑生效