如何在Mac OS X Yosemite(10.10)上安装mcrypt扩展。

8
我已将我的Mac OS X更新为Yosemite,但这样做会覆盖我所有的开发环境。因此,现在要在本地apache上运行Laravel 4,我需要安装Mcrypt扩展,但我尝试过的所有方法都失败了,即使是在OS X Mavericks(10.9)上成功的步骤也是如此。
有人遇到同样的问题吗? 谢谢提前。
干杯

2
Mac OS X 10.10 可能太新,目前可能还没有兼容的编译模块。你可能需要手动编译该模块... - Steven V
另一个选择是使用Laravel Homestead创建虚拟开发环境 - http://laravel.com/docs/homestead?version=4.2 - 如果VirtualBox在Yosemite上运行。 - glendaviesnz
你需要使用Homebrew或类似工具进行编译:https://lastzero.net/2013/08/howto-install-php-5-5-and-phpunit-on-os-x-via-homebrew/ - Jannie Theunissen
如果你不介意更新你的php,你可以尝试这里的自动脚本:http://php-osx.liip.ch/ 它会安装最新的php和最常用的扩展,而且不会产生冲突。 - ricardgf
4个回答

8

我刚刚使用Homebrew在我的Mavericks安装上安装了它,效果出乎意料的好。无法确定它是否在Yosemite上能够如此顺利地运行,但值得一试。

Homebrew

brew install autoconf
brew install mcrypt

Macports

  1. Check PHP version

    php -v
    
  2. Update Macports

    sudo port -v selfupdate
    
  3. Download & install the appropriate version..

    sudo port install php55-mcrypt
    

    now dummy proof it..

  4. Find where Macports put the file mcrypt.so and copy it to all instances of /php/extensions/no-debug-... folder. If you have that directory structure in multiple places, copy it to all of them. So every php/extensions/no-debug.. folder on your computer has a copy of mcrypt.so

    sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so /usr/lib/php/extensions/no-debug-non-zts-20090626/
    
  5. Determine where your php.ini file is and make sure it's the one your actually using because you may have this file in more than 1 place. Do this to all php.ini files you find..

    Within that file find and uncomment the following line. If it's commented out, uncomment it. If it's not in the file at all, add it. In my default php.ini file I found this on line 536:

    extension=mcrypt.so
    

编译

  1. Download mcrypt

    curl -O http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
    
  2. Uncompress it

    tar -zxvf libmcrypt-2.5.8.tar.gz
    
  3. Configure, build, and install

    ./configure && make && sudo make install
    
  4. Download Autoconf

    curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
    
  5. Uncompress it

    tar xvfz autoconf-latest.tar.gz
    
  6. Configure, build, and install

    ./configure && make && sudo make install
    

Apache

无论你使用哪种方法安装它,完成后都应该重新启动Apache。


  1. Restart Apache

    sudo apachectl restart
    

2

我刚刚安装了这些插件,MAMP等并没有被安装。

brew tap josegonzalez/homebrew-php
brew install php55-mcrypt

奇怪的是,我不得不重新安装才能正确安装它。

brew reinstall php55-mcrypt

然而,这也重新安装了PHP5.5源代码,但是没关系,我这边一切都正常工作。


1
我有同样的问题。但是,我在本地开发中使用MAMP。因此,我只需要将php文件链接到MAMP的版本上,一切都正常工作了。
如果使用homebrew,请尝试重新安装或重新链接您的php安装。
我相信我可以帮助您恢复工作,所以如果那没用,请告诉我。

我遇到了安装mcrypt扩展的同样问题。我的Homebrew出了问题。我需要重新安装Homebrew吗?(或者只是修复它?) - Chandan Gupta
我最终移除了MAMP并使用Vagrant进行本地开发。这使得使用homebrew安装本地PHP变得更加容易。 - TheTC
你是否在本地开发中使用MAMP?如果是的话...你只需要备份当前的php可执行文件。然后将MAMP的php可执行文件链接到同一个文件夹中即可。 - TheTC

1

首先从homebrew安装libtool,它是10.10 Yosemite的一个依赖项。

brew reinstall libtool --universal && brew unlink libtool && brew link libtool

然后CD到您的PHP目录。
cd /usr/local/php5

并将其放入您的php.d目录中

cd php.d

最后,快速执行 ls 命令查看您正在使用哪些扩展:

ls -l

如果您看到包含“mcrypt”的重复条目,则需要打开其中一个,并注释掉该行:
extension=mcrypt.so

;;extension=mcrypt.so

但只有其中一个。对我来说,它是mcrypt.ini。所以...
sudo nano mcrypt.ini

添加了这行文字,完成了!

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接