昨天(也就是2018-09-25)新版本的macOS Mojave 10.14正式开放下载,我如此时尚,自然是要第一时间下载安装的(这句话好熟悉的样子)。
今天开发时发现有些PHP扩展无法使用,提示版本不兼容需要重新编译。
这个自然是难不倒我的,于是:下载扩展源码包、解压后进入文件夹、执行phpize报错了。。。。
$ phpize grep: /usr/include/php/main/php.h: No such file or directory grep: /usr/include/php/Zend/zend_modules.h: No such file or directory grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory Configuring for: PHP Api Version: Zend Module Api No: Zend Extension Api No:
缺少PHP的header头文件,再一看/usr/include
文件夹根本不存在,想必是Xcode command line tools
没有安装完全(我macOS 10.13版本装过的)?熟练的敲出如下命令:
$ xcode-select --install xcode-select: note: install requested for command line developer tools
静等了一会安装完成,一看/usr/include
文件夹还是不存在,难道升级系统后System Integrity Protection
自动打开导致文件写不进?接着执行:
$ csrutil status System Integrity Protection status: disabled.
SIP
处于禁用状态,没有问题。
再安装一遍Xcode command line tools
试试:
$ xcode-select --install
xcode-select: error: command line tools are already installed...
不给装了,这可如何是好。。
于是各种吃力爬英文网站,最后终于让我找到了,只需执行下列命令安装header头文件SDK即可:
$ cd /Library/Developer/CommandLineTools/Packages/ $ open macOS_SDK_headers_for_macOS_10.14.pkg
安装完成再一看/usr/include
文件夹和里面的都文件都回来了。
接下里一切都简单多了,再次(编译过PHP扩展的一看就懂):
$ phpize
$ ./configure
$ make
$ sudo make install
以上就是解决问题的大概过程,然后一一顺利解决掉所有不兼容的PHP扩展,很开心。
顺便记录一下如何将自己的mac变成一台开发机器:
# csrutil disable # 需要在恢复模式下运行命令,具体请自行搜索。 $ xcode-select --install # 安装常用开发工具,如:git等。 $ cd /Library/Developer/CommandLineTools/Packages/ $ open macOS_SDK_headers_for_macOS_10.14.pkg $ sudo DevToolsSecurity -enable # 将系统置于开发模式