简体   繁体   English

无法使用自制软件和 php7.4 安装 mcrypt

[英]Cannot install mcrypt with homebrew and php7.4

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

Homebrew: 2.5.12自制软件:2.5.12

PEAR Version: 1.10.12梨版本:1.10.12

I just upgraded the php on my mac from php7.1 to php7.4 with homebrew (brew install php@7.4).我刚刚用自制软件 (brew install php@7.4) 将我 mac 上的 php 从 php7.1 升级到 php7.4。

Then, when I try to install mcrypt extension, I got the error:然后,当我尝试安装 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

Here is what I did:这是我所做的:

  1. brew isntall mcrypt brew isntall mcrypt
  2. install the pecl安装 pecl
  3. sudo pecl install mcrypt -- The error goes here. sudo pecl install mcrypt——错误出现在这里。

What I tried:我尝试了什么:

  1. Located the mcrypt.h and put manually the file to the several locations (based on the php-config), not work.找到 mcrypt.h 并手动将文件放到几个位置(基于 php-config),但不起作用。

  2. Cleaned the brew and reinstall/relink the mcrypt(libmcrypt), not work.清理 brew 并重新安装/重新链接 mcrypt(libmcrypt),但不起作用。

  3. Removed the legacy mcrypt files of the old brew version.删除了旧 brew 版本的遗留 mcrypt 文件。

I ran into the same problem.我遇到了同样的问题。 So after installing libmcrypt with brew install mcrypt it seems like configure is not able to resolve the path to mcrypt.h automatically.因此,在使用brew install mcrypt安装 libmcrypt 后,configure 似乎无法自动解析 mcrypt.h 的路径。 It also does not work to specify the CPPFLAGS or giving the homebrew include path.指定 CPPFLAGS 或提供自制包含路径也不起作用。

But I found a solution that works for me by giving pecl the install location of mcrypt in the Homebrew Cellar.但是我通过在 Homebrew Cellar 中为 pecl 提供 mcrypt 的安装位置找到了一个适合我的解决方案。 This is what the following code does automatically:这是以下代码自动执行的操作:

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

The problem here is the configure command can't find the libmcrypt installed by homebrew这里的问题是configure命令找不到homebrew安装的libmcrypt

You can你可以

  1. Download the source code of mcrypt-1.0.4, then cd in the folder下载mcrypt-1.0.4的源码,然后cd到文件夹

  2. run "phpize"运行“phpize”

  3. run "./configure --with-mcrypt=/opt/homebrew/Cellar/mcrypt/2.6.8", you can change the path here with your path for homebrew lib运行“./configure --with-mcrypt=/opt/homebrew/Cellar/mcrypt/2.6.8”,您可以在此处使用自制软件库的路径更改路径

  4. run "make && make install"运行“制作 && 制作安装”

  5. add extension=mcrypt.so to your config file将 extension=mcrypt.so 添加到您的配置文件

ps: Use php -i | grep "Loaded Configuration File" ps:使用php -i | grep "Loaded Configuration File" php -i | grep "Loaded Configuration File" to locate your php configure file php -i | grep "Loaded Configuration File"找到您的 php 配置文件

in case of an error on macOS use the complete path in php.ini like:如果macOS出现错误,请使用 php.ini 中的完整路径,例如:

extension="/opt/homebrew/Cellar/php/8.1.9/pecl/20210902/mcrypt.so"

if you using brew try this:如果你使用brew试试这个:

1. Unistall existing php then Install shivammathur/php 1.卸载现有的 php然后安装 shivammathur/php

add shivammathur php添加 shivammathur php

brew tap shivammathur/php

change php version with you needed (5.6 or 7.2 or 7.4 or 8.1 or next version)根据需要更改 php 版本(5.6 或 7.2 或 7.4 或 8.1 或下一版本)

brew install shivammathur/php/php@7.4

2.Install shivammathur/extensions it s will add extension to php then 2.安装 shivammathur/extensions 它将添加扩展到 php 然后

brew tap shivammathur/extensions

brew install shivammathur/extensions/mcrypt@7.4

then you install mcrypt with same version as php version然后安装与 php 版本相同的 mcrypt

brew install mcrypt@7.4

then restart httpd然后重启httpd

brew services restart httpd

Ref:参考:

https://github.com/shivammathur/homebrew-php https://github.com/shivammathur/homebrew-php

https://github.com/shivammathur/homebrew-extensions https://github.com/shivammathur/homebrew-extensions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM