• 解决在Apple Silicon (M1)安装php MongoDB扩展失败


    在MacBook Pro上已经安装了php7.4.24

    ➜php -v
    PHP 7.4.24 (cli) (built: Oct 11 2021 08:58:20) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.24, Copyright (c), by Zend Technologies
    

    尝试通过以下命令来安装MongoDB扩展
    /opt/homebrew/opt/php@7.4/bin/pecl install mongodb
    但是安装失败了

    In file included from /private/tmp/pear/temp/mongodb/php_phongo.c:29:
    In file included from /opt/homebrew/Cellar/php@7.4/7.4.24_1/include/php/ext/spl/spl_iterators.h:24:
    /opt/homebrew/Cellar/php@7.4/7.4.24_1/include/php/ext/pcre/php_pcre.h:25:10: fatal error: 'pcre2.h' file not found
    #include "pcre2.h"
             ^~~~~~~~~
    1 error generated.
    make: *** [php_phongo.lo] Error 1
    ERROR: `make' failed
    

    解决办法:

    brew install pcre
    查找pcre2.h头文件的位置

    ➜ find /opt/homebrew -name pcre2.h
    /opt/homebrew/include/pcre2.h
    /opt/homebrew/Cellar/pcre2/10.37_1/include/pcre2.h
    /opt/homebrew/Cellar/pcre2/10.38/include/pcre2.h
    

    软连接到使用的位置
    ln -s /opt/homebrew/include/pcre2.h /opt/homebrew/Cellar/php@7.4/7.4.24_1/include/php/ext/pcre/pcre2.h
    重新执行安装命令

    ➜ /opt/homebrew/opt/php@7.4/bin/pecl install mongodb
    Build process completed successfully
    Installing '/opt/homebrew/Cellar/php@7.4/7.4.24_1/pecl/20190902/mongodb.so'
    install ok: channel://pecl.php.net/mongodb-1.10.0
    Extension mongodb enabled in php.ini
    

    安装成功

  • 相关阅读:
    [hdu-2048] 神、上帝以及老天爷
    or1200中IMMU分析(续)
    Java Applet读写client串口——终极篇
    树莓派_Linux串口编程_实现自发自收
    2014百度实习生面试题(部分)具体解释
    Leetcode
    eclipse+webservice开发实例
    现有一些开源ESB总线的比較
    《HTML5 从入门到精通--7.6.3 单元格垂直跨度——rowspan》
    百度究竟是哪国的公司
  • 原文地址:https://www.cnblogs.com/ilizhu/p/15423995.html
Copyright © 2020-2023  润新知