在 OSX 10.8.2 - PHP 5.3.15 上使用自制软件安装 mcrypt
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14357107/
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
Installing mcrypt on OSX 10.8.2 - PHP 5.3.15 with homebrew
提问by Matanya
I've successfully installed mcryptvia homebrewbut I'm struggling to find the path to mcrypt.soto include it as an extension in php.ini.
我已成功安装mcrypt通过,homebrew但我正在努力寻找将mcrypt.so其作为扩展包含在php.ini.
mcrypt was installed at /usr/local/Cellar/mcrypt/2.5.8. Tree:
mcrypt 安装在/usr/local/Cellar/mcrypt/2.5.8. 树:
-- AUTHORS
|-- ChangeLog
|-- INSTALL_RECEIPT.json
|-- NEWS
|-- README
|-- TODO
|-- bin
| `-- libmcrypt-config
|-- include
| |-- mcrypt.h
| `-- mutils
| `-- mcrypt.h
|-- lib
| |-- libmcrypt.4.4.8.dylib
| |-- libmcrypt.4.dylib -> libmcrypt.4.4.8.dylib
| `-- libmcrypt.dylib -> libmcrypt.4.4.8.dylib
`-- share
|-- aclocal
| `-- libmcrypt.m4
`-- man
`-- man3
`-- mcrypt.3
I tried to include mcrypt.hin php.ini:
我试图包括mcrypt.h在php.ini:
extension="/usr/local/Cellar/mcrypt/2.5.8/include/mcrypt.h"
and then restarted apache. but it didn't work.
然后重新启动apache。但它没有用。
when I run php in the terminal I get:
当我在终端中运行 php 时,我得到:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/Cellar/mcrypt/2.5.8/include/mcrypt.h' - dlopen(/usr/local/Cellar/mcrypt/2.5.8/include/mcrypt.h, 9):
image not found in Unknown on line 0
回答by pinxi
First check if brew is up-to-date:brew doctor
首先检查 brew 是否是最新的:brew doctor
Second install mcrypt based on php version:brew install php53-mcrypt
第二次安装基于php版本的mcrypt:brew install php53-mcrypt
NB: Step three below is not required on recent versions of brew:
注意:最新版本的 brew 不需要下面的第三步:
Third open php.ini file and add reference:sudo vi /private/etc/php.iniextension="/usr/local/Cellar/php53-mcrypt/5.3.25/mcrypt.so"
第三次打开 php.ini 文件并添加引用:sudo vi /private/etc/php.iniextension="/usr/local/Cellar/php53-mcrypt/5.3.25/mcrypt.so"
Finally, restart apache:sudo apachectl restart
最后,重启apache:sudo apachectl restart
回答by Matanya
After wondering for hours through different advices, this oneworked for me (Installed via MacPorts):
在通过不同的建议想了几个小时之后,这个对我有用(通过 MacPorts 安装):
Courtesy of Chris Brewer:
克里斯·布鲁尔( Chris Brewer) 提供:
Download and install MacPorts from http://macports.org.
下载并安装 MacPorts http://macports.org.
The following steps are performed in the Terminal:
在终端中执行以下步骤:
Force MacPorts to update (will only work if Apple's Xcode installed):
强制 MacPorts 更新(只有在安装了 Apple 的 Xcode 时才有效):
sudo port -v selfupdate
Now, install memcached:
现在,安装 memcached:
sudo port install php5-mcrypt
Copy the newly created shared object for mcrypt into Mac OS X's default PHP5 extension directory:
将新创建的 mcrypt 共享对象复制到 Mac OS X 的默认 PHP5 扩展目录中:
sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so /usr/lib/php/extensions/no-debug-non-zts-20090626/
Next, you need to edit php.ini to add the extensions. Find the phrase Dynamic Extensions, and add:
接下来,您需要编辑 php.ini 以添加扩展。找到短语动态扩展,并添加:
extension=mcrypt.so
And finally, restart Apache:
最后,重启 Apache:
sudo apachectl restart
sudo apachectl restart
回答by mariowise
I've solved the problem with this
我已经解决了这个问题
brew install php54-mcrypt --without-homebrew-php
Then I add this line to /etc/php.ini.
然后我将此行添加到/etc/php.ini.
extension="/usr/local/Cellar/php54-mcrypt/5.4.24/mcrypt.so"
If this file doesn't exists you'll need to copy it from /etc/php.ini.default. Also I check the version of my php with php -v(And it was 5.4.x)
如果此文件不存在,则需要从/etc/php.ini.default. 我还检查了我的 php 版本php -v(它是 5.4.x)
回答by Harish Prasanna
Worked like a piece of cake with this.
用这个工作就像小菜一碟。
$ brew install mcrypt
Warning: mcrypt-2.6.8 already installed
$ brew install php55-mcrypt
Warning: php55-mcrypt-5.5.20 already installed
Then test it out:
然后测试一下:
$ 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
回答by Oomta
This may prove useful...
这可能证明有用...
- brew tap homebrew/homebrew-php
- brew install php56-mcrypt
- 酿造自来水自制软件/自制软件-php
- brew 安装 php56-mcrypt
回答by SteckDEV
I appreciate the work you did on this! This worked for me. I am on a mac and it was looking for xcode. The Developer location hadn't been set so I had to do all of this.
我很欣赏你在这方面所做的工作!这对我有用。我在 Mac 上,它正在寻找 xcode。尚未设置开发人员位置,因此我必须完成所有这些操作。
(RESOLVE THE DEVELOPER PATH) How can I resolve "Error: No developer directory found at /Developer"?
(解决开发人员路径) 如何解决“错误:在 /Developer 中找不到开发人员目录”?
- sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
- 须藤 xcode-select -switch /Applications/Xcode.app/Contents/Developer
(SIGN THE AGREEMENT TO USE XCODE)
(签署协议使用Xcode)
- sudo xcodebuild -license
- 须藤 xcodebuild -license
Lastly follow the above steps!
最后按照以上步骤操作!

