在mac php7.2 MAMP上安装mcrypt
Posted
技术标签:
【中文标题】在mac php7.2 MAMP上安装mcrypt【英文标题】:Install mcrypt on mac php7.2 MAMP 【发布时间】:2018-11-13 08:48:16 【问题描述】:我尝试按照此处关于堆栈溢出的大部分教程进行操作,但没有成功。
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
这是我在终端上查看版本时得到的结果
AVMBP:~ AV$ 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
当我尝试在终端上安装 mcrypt 时,我得到了以下结果
AVsMBP:~ AV$ 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`
AVs-Macbook-Pro:~ AV$ brew reinstall mcrypt
==> Reinstalling mcrypt
==> Downloading https://homebrew.bintray.com/bottles/mcrypt-2.6.8.yosemite.bottl
Already downloaded: /Users/AV/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
AVs-Macbook-Pro:~ AV$
然后,我检查是否安装了 mcrypt
brew search mcrypt
这是我得到的
AVs-Macbook-Pro:~ AV$ brew search mcrypt
==> Searching local taps...
mcrypt ✔ libtomcrypt
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...
通过终端成功安装mcrypt后,我在php.ini中添加了mcrypt.so扩展。
/Applications/MAMP/bin/php/php7.2.1/conf/php.ini
extension=mcrypt.so
我验证了是否安装了扩展程序,我得到了这个;
AVs-Macbook-Pro:~ AV$ 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
AVs-Macbook-Pro:~ AV$
重启了系统,运行php系统时还是出现这个错误
An Error Was Encountered
The Encrypt library requires the Mcrypt extension.
请帮帮我。提前致谢!
【问题讨论】:
【参考方案1】:如果您没有正确安装 mcrypt 库,请尝试以下操作:
https://gist.github.com/idleberg/24479f34dc5007e50d47
或查看http://www.php.net/manual/en/mcrypt.setup.php了解其他信息。
如果您使用的是共享主机,您可以要求您的提供商安装它。
在 OSX localhost 中,您可以通过自制软件轻松安装 mcrypt - 正如您在上面尝试的那样:
brew install mcrypt
然后将此行添加到您的 php.ini 文件中。 您可以从上面的自制程序输出中看到:“/usr/local/Cellar/mcrypt/2.6.8”
extension="/usr/local/Cellar/mcrypt/2.6.8/mcrypt.so"
不要忘记重启服务器以使编辑生效
【讨论】:
以上是关于在mac php7.2 MAMP上安装mcrypt的主要内容,如果未能解决你的问题,请参考以下文章
使用 MAMP 和 MAC 在 php myadmin 上获取错误 500