在 OSX Mountain Lion 上为 PHP 安装 mcrypt 扩展 [英] Installing mcrypt extension for PHP on OSX Mountain Lion

查看:29
本文介绍了在 OSX Mountain Lion 上为 PHP 安装 mcrypt 扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于潜在的 n00b 问题提前致歉,我正在尝试在我的 OSX Mountain Lion 机器上安装适用于 PHP 的 mcrypt 扩展.

Apologies in advance for the potential n00b questions, I am trying to install the mcrypt extension for PHP on my OSX Mountain Lion machine.

终端中的以下步骤是我迄今为止为实现 PHP 安装所做的

The following steps in terminal is what I have done so far to achieve my PHP install

cd /path/to/downloaded/php-5.3.21/ext/mcrypt/
/usr/bin/phpize
./configure
cd /path/to/downloaded/php-5.3.21
./configure --with-config-file-path=/private/etc/php.ini --with-apxs2=/usr/sbin/apxs
make
sudo make install

这似乎运行良好并且可以很好地安装 PHP 5.3.21.我已经完成了

Which seems to work well and installs PHP 5.3.21 fine. I have then done

sudo nano /private/etc/php.ini

并包含

extension=mcrypt.so

随着 Apache 重新启动,phpinfo() 不会显示已加载 mcrypt 扩展.

Along with an Apache restart, phpinfo() doesn't show that the mcrypt extension is loaded.

然后我尝试在 php.ini 中指定 extension_dir,但还是没有成功.

I then tried to specify the extension_dir inside php.ini, again with no luck.

我已经完成了

locate mcrypt.so
/opt/local/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so
/usr/local/Cellar/php53-mcrypt/5.3.18/mcrypt.so

并尝试将两个目录作为 extension_dir,但没有成功.

And tried both directories as the extension_dir, with no luck.

经过多次谷歌搜索后,我也尝试了以下方法

I have also tried the following, after much Googling

./configure --with-config-file-path=/private/etc/php.ini --with-apxs2=/usr/sbin/apxs --with-mcrypt

这似乎工作正常,但是在make"时,它返回

Which seems to work OK, but then upon "make", it returns

ext/mcrypt/mcrypt.o: No such file or directory
ext/mcrypt/mcrypt_filter.o: No such file or directory

再一次,没有成功.

我做错了什么?似乎 mcrypt.so 的物理编译没有发生,或者编译不正确,因为我怀疑在 locate 下发现了另一个 mcrypt.so?

What am I doing wrong? It seems like the physical compile of mcrypt.so is not happening, or is compiling incorrectly as I would suspect there to be another mcrypt.so found under locate?

有人帮忙吗?我浏览了一页又一页的 Google 搜索,但都没有运气!

Anyone please help? I've gone through pages upon pages of Google searches with no luck!

推荐答案

我倾向于在 Mac 上使用 Homebrew.它将为您安装和配置所有东西.
http://mxcl.github.com/homebrew/

I tend to use Homebrew on Mac. It will install and configure all the stuff for you.
http://mxcl.github.com/homebrew/

然后你应该可以用 brew install mcrypt php53-mcrypt 安装它,它就会正常工作 (tm).

Then you should be able to install it with brew install mcrypt php53-mcrypt and it'll Just Work (tm).

您可以将 53 替换为您使用的任何 PHP 版本,例如 php56-mcryptphp70-mcrypt.如果您不确定,请使用 brew search php.

You can replace the 53 with whatever version of PHP you're using, such as php56-mcrypt or php70-mcrypt. If you're not sure, use brew search php.

还请记住,如果您使用内置的 Mac PHP,它安装在 /usr/bin 中,您可以在 which php 处查看您使用的是哪个 php终端,它会返回路径.

Do also remember that if you are using the built in Mac PHP it's installed into /usr/bin you can see which php you are using with which php at the terminal and it'll return the path.

这篇关于在 OSX Mountain Lion 上为 PHP 安装 mcrypt 扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆