mac php安装mongodb扩展 报错 'Security/Security.h' file not found

Mac下PHP安装MongoDB扩展的折腾记录

最近换了个电脑,需要重新部署下环境,其他的还好,基本跟着网上各种指导都装的差不多,但是在准备安装mongodb的时候碰上了点问题,来回折腾了三四天,主要是卡在安装php的mongodb扩展,记录下,以供参考。

1、一开始尝试使用  pecl   install  mongodb     安装,但是也各种报错,包括 直接就解压下载的包失败的(unpack …………)、ldylib.o not found  等错误,很麻烦,于是最后还是决定手动编译安装;

2、以下是完整的操作步骤:


//下载压缩包
1)wget http://pecl.php.net/get/mongodb-1.5.5.tgz

//解压
2)tar -zxvf mongodb-1.5.5.tgz 

//进入解压目录
3)cd mongodb-1.5.5

//开始编译安装

4)/usr/local/Cellar/php\@7.2/7.2.20/bin/phpize 

注意:我一开始直接运行的  phpize,虽然能执行,但是在后面安装的时候也会有各种错,具体原因我也没搞清楚,来回试好几遍后指定了绝对路径执行 phpize,所以建议搞清楚自己php的安装目录,然后指定绝对路径执行phpize


5)./configure --with-php-config=/usr/local/Cellar/php\@7.2/7.2.20/bin/php-config --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s/

注意:跟上面一样,也请确定好自己的php安装目录再执行configure


6)make && make install






这个时候报错,/private/tmp/pear/install/mongodb/src/libmongoc/src/libmongoc/src/mongoc/mongoc-rand-common-crypto.c:25:10: fatal error: 'Security/Security.h' file not found,不能忍啊,折腾那么久眼看着成功了又报错。于是一番搜索后,在参考了下面两篇后总算解决了,不过感觉描述的不是很清楚,所以今天自己重新整理了下,接着装;

参考:https://blog.youkuaiyun.com/drdongshiye/article/details/90143302,另一篇忘记是哪个了。。。。。。

继续

7)cd include/

8)ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Security.framework/Versions/A/Headers/ Security

9)ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Versions/A/Headers/ CoreFoundation

10)brew install pcre

11)cd ..

12)./configure --with-php-config=/usr/local/Cellar/php\@7.2/7.2.20/bin/php-config --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2s/

13)make && make install

14)
php -i | grep extension_dir //查看PHP扩展包存储目录,这里为eextension_dir => /usr/local/lib/php/pecl/20170718 => /usr/local/lib/php/pecl/20170718

ls /usr/local/lib/php/pecl/20170718 //查看目录中是否有mongodb.so文件

编辑php.ini,在extension区域添加mongodb扩展

extension=mongodb.so

至此,就安装成功了,哈哈

查看:

php -m | grep mongodb

 

本文部分内容也借鉴了:https://blog.youkuaiyun.com/chinawangfei/article/details/80301725

以上,

感谢大家浏览,祝好

# 添加官方源(如前所述) curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | \ sudo gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyirng.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | \ sudo tee /etc/apt/sources.list.d/pgdg.list sudo apt update sudo apt install -y postgresql-16 deb [signed-by=/usr/share/keyrings/postgresql-archive-keyirng.gpg] http://apt.postgresql.org/pub/repos/apt focal-pgdg main Hit:1 http://mirrors.tencentyun.com/ubuntu focal InRelease Hit:2 http://mirrors.tencentyun.com/ubuntu focal-updates InRelease Hit:3 http://mirrors.tencentyun.com/ubuntu focal-backports InRelease Hit:4 http://mirrors.tencentyun.com/ubuntu focal-security InRelease Hit:5 https://download.docker.com/linux/ubuntu focal InRelease Hit:6 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease Hit:7 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0 InRelease Ign:8 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease Err:9 http://apt.postgresql.org/pub/repos/apt focal-pgdg Release 404 Not Found [IP: 198.18.0.12 80] Hit:10 https://packages.redis.io/deb focal InRelease Reading package lists... Done E: The repository 'http://apt.postgresql.org/pub/repos/apt focal-pgdg Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package postgresql-16
11-13
➜ NodeJS # 1. 备份重要数据 e/NodeJS-backup # 2. 更新当前系统 ➜ NodeJS sudo cp -r /workspace/NodeJS /workspace/NodeJS-backup do apt upgrade -y # 3. 安装升级工具 sudo apt install update-manager-core -y # 4. 执行发行版升级 sudo do-release-upgrade ➜ NodeJS ➜ NodeJS # 2. 更新当前系统 ➜ NodeJS sudo apt update && sudo apt upgrade -y Hit:1 http://mirrors.tencentyun.com/ubuntu focal InRelease Hit:2 http://mirrors.tencentyun.com/ubuntu focal-updates InRelease Hit:3 http://mirrors.tencentyun.com/ubuntu focal-backports InRelease Hit:4 http://mirrors.tencentyun.com/ubuntu focal-security InRelease Hit:5 https://download.docker.com/linux/ubuntu focal InRelease Hit:6 https://packages.redis.io/deb focal InRelease Hit:7 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease Ign:8 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease Err:9 http://apt.postgresql.org/pub/repos/apt focal-pgdg Release 404 Not Found [IP: 198.18.0.8 80] Hit:10 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0 InRelease Reading package lists... Done E: The repository 'http://apt.postgresql.org/pub/repos/apt focal-pgdg Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. ➜ NodeJS ➜ NodeJS # 3. 安装升级工具 ➜ NodeJS sudo apt install update-manager-core -y Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libboost-filesystem1.71.0 libboost-iostreams1.71.0 libboost-program-options1.71.0 libgoogle-perftools4 libhiredis0.14 libjemalloc2 liblua5.1-0 libpcap0.8 libsnappy1v5 libtcmalloc-minimal4 libunwind8 libyaml-cpp0.6 lua-bitop lua-cjson Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: distro-info python3-distro-info python3-distupgrade python3-update-manager python3-yaml ubuntu-advantage-tools ubuntu-pro-client ubuntu-pro-client-l10n ubuntu-release-upgrader-core Suggested packages: shunit2 python3-launchpadlib The following NEW packages will be installed: distro-info python3-distro-info python3-distupgrade python3-update-manager python3-yaml ubuntu-advantage-tools ubuntu-pro-client ubuntu-pro-client-l10n ubuntu-release-upgrader-core update-manager-core 0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded. Need to get 603 kB of archives. After this operation, 3,696 kB of additional disk space will be used. Get:1 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 python3-yaml amd64 5.3.1-1ubuntu0.1 [136 kB] Get:2 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 distro-info amd64 0.23ubuntu1.1 [17.1 kB] Get:3 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 ubuntu-pro-client amd64 36ubuntu0~20.04 [236 kB] Get:4 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 ubuntu-advantage-tools all 36ubuntu0~20.04 [11.0 kB] Get:5 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 ubuntu-pro-client-l10n amd64 36ubuntu0~20.04 [18.7 kB] Get:6 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 python3-distro-info all 0.23ubuntu1.1 [5,944 B] Get:7 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 python3-update-manager all 1:20.04.10.23 [38.5 kB] Get:8 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 python3-distupgrade all 1:20.04.41 [105 kB] Get:9 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 ubuntu-release-upgrader-core all 1:20.04.41 [24.3 kB] Get:10 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 update-manager-core all 1:20.04.10.23 [11.6 kB] Fetched 603 kB in 0s (4,465 kB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package python3-yaml. (Reading database ... 38118 files and directories currently installed.) Preparing to unpack .../0-python3-yaml_5.3.1-1ubuntu0.1_amd64.deb ... Unpacking python3-yaml (5.3.1-1ubuntu0.1) ... Selecting previously unselected package distro-info. Preparing to unpack .../1-distro-info_0.23ubuntu1.1_amd64.deb ... Unpacking distro-info (0.23ubuntu1.1) ... Selecting previously unselected package ubuntu-pro-client. Preparing to unpack .../2-ubuntu-pro-client_36ubuntu0~20.04_amd64.deb ... Unpacking ubuntu-pro-client (36ubuntu0~20.04) ... Selecting previously unselected package ubuntu-advantage-tools. Preparing to unpack .../3-ubuntu-advantage-tools_36ubuntu0~20.04_all.deb ... Unpacking ubuntu-advantage-tools (36ubuntu0~20.04) ... Selecting previously unselected package ubuntu-pro-client-l10n. Preparing to unpack .../4-ubuntu-pro-client-l10n_36ubuntu0~20.04_amd64.deb ... Unpacking ubuntu-pro-client-l10n (36ubuntu0~20.04) ... Selecting previously unselected package python3-distro-info. Preparing to unpack .../5-python3-distro-info_0.23ubuntu1.1_all.deb ... Unpacking python3-distro-info (0.23ubuntu1.1) ... Selecting previously unselected package python3-update-manager. Preparing to unpack .../6-python3-update-manager_1%3a20.04.10.23_all.deb ... Unpacking python3-update-manager (1:20.04.10.23) ... Selecting previously unselected package python3-distupgrade. Preparing to unpack .../7-python3-distupgrade_1%3a20.04.41_all.deb ... Unpacking python3-distupgrade (1:20.04.41) ... Selecting previously unselected package ubuntu-release-upgrader-core. Preparing to unpack .../8-ubuntu-release-upgrader-core_1%3a20.04.41_all.deb ... Unpacking ubuntu-release-upgrader-core (1:20.04.41) ... Selecting previously unselected package update-manager-core. Preparing to unpack .../9-update-manager-core_1%3a20.04.10.23_all.deb ... Unpacking update-manager-core (1:20.04.10.23) ... Setting up distro-info (0.23ubuntu1.1) ... Setting up python3-yaml (5.3.1-1ubuntu0.1) ... Setting up python3-distro-info (0.23ubuntu1.1) ... Setting up ubuntu-pro-client (36ubuntu0~20.04) ... debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.) debconf: falling back to frontend: Readline Created symlink /etc/systemd/system/multi-user.target.wants/ua-reboot-cmds.service → /lib/systemd/system/ua-reboot-cmds.service. Created symlink /etc/systemd/system/timers.target.wants/ua-timer.timer → /lib/systemd/system/ua-timer.timer. Created symlink /etc/systemd/system/multi-user.target.wants/ubuntu-advantage.service → /lib/systemd/system/ubuntu-advantage.service. Setting up ubuntu-pro-client-l10n (36ubuntu0~20.04) ... Setting up ubuntu-advantage-tools (36ubuntu0~20.04) ... debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.) debconf: falling back to frontend: Readline Setting up python3-update-manager (1:20.04.10.23) ... Setting up python3-distupgrade (1:20.04.41) ... Setting up ubuntu-release-upgrader-core (1:20.04.41) ... Setting up update-manager-core (1:20.04.10.23) ... Processing triggers for man-db (2.9.1-1) ...
最新发布
11-13
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值