【问题标题】:Cannot install mcrypt with homebrew and php7.4无法使用自制软件和 php7.4 安装 mcrypt
【发布时间】:2021-03-13 03:21:20
【问题描述】:

操作系统:macOS 11(大苏尔)

自制:2.5.12

梨版本:1.10.12

我刚刚使用 homebrew (brew install php@7.4) 将我的 mac 上的 php 从 php7.1 升级到 php7.4。

然后,当我尝试安装 mcrypt 扩展时,我得到了错误:

configure: error: mcrypt.h not found. Please reinstall libmcrypt.
ERROR: `/private/tmp/pear/install/mcrypt/configure --with-php-config=/usr/local/homebrew/opt/php@7.4/bin/php-config --with-mcrypt' failed

这是我所做的:

  1. brew isntall mcrypt
  2. 安装 pecl
  3. sudo pecl install mcrypt -- 错误出现在这里。

我尝试了什么:

  1. 找到 mcrypt.h 并将文件手动放到几个位置(基于 php-config),不起作用。

  2. 清理了 brew 并重新安装/重新链接 mcrypt(libmcrypt),不起作用。

  3. 删除了旧 brew 版本的遗留 mcrypt 文件。

【问题讨论】:

  • 这个成功了吗?遇到同样的问题。
  • 我放弃了用自制软件安装php7.4。终于用 MAMP Pro 获得了我的开发环境。

标签: php macos homebrew mcrypt


【解决方案1】:

我遇到了同样的问题。因此,在使用 brew install mcrypt 安装 libmcrypt 之后,似乎 configure 无法自动解析 mcrypt.h 的路径。指定 CPPFLAGS 或提供自制包含路径也不起作用。

但我通过在 Homebrew Cellar 中为 pecl 提供 mcrypt 的安装位置找到了一个适合我的解决方案。这是以下代码自动执行的操作:

pecl install mcrypt <<<"$(ls -d $(brew --prefix)/Cellar/mcrypt/* | tail -1)"

【讨论】:

  • 非常感谢您!它就像魔术一样工作。在我的 Mac OS Catalina 上,通过 homebrew 安装了 php 7.4。
【解决方案2】:

这里的问题是configure命令找不到homebrew安装的libmcrypt

你可以

  1. 下载mcrypt-1.0.4的源码,然后cd到文件夹中

  2. 运行“phpize”

  3. 运行“./configure --with-mcrypt=/opt/homebrew/Cellar/mcrypt/2.6.8”,您可以在此处使用自制软件库的路径更改路径

  4. 运行“make && make install”

  5. 将 extension=mcrypt.so 添加到您的配置文件中

ps:使用php -i | grep "Loaded Configuration File"定位你的php配置文件

【讨论】:

    猜你喜欢
    • 2014-12-06
    • 2020-09-02
    • 2019-09-14
    • 1970-01-01
    • 1970-01-01
    • 2017-09-11
    • 2021-09-26
    相关资源
    最近更新 更多