MacOS 每次更新都会给编译 PHP 扩展带来一些麻烦,今天在安装 PCNTL 扩展的时候又遇上了,所以记录一下。
我的系统版本是 macOS High Sierra 10.13.3,PHP 版本是 PHP-7.1.7。
首先我从官网下载跟我系统版本相同的 PHP,默认下载到 Downloads 目录下面,之后运行 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
使用 vim 查看 phpize,发现 phpize 默认的根目录是 /usr/include/php,我在 /user/include/ 目录下新建 php 目录,并将下载的代码 mv 到该目录下。