【报错1】
./configure 时报错
conftest.c:9:10: fatal error: 'ac_nonexistent.h' file not found
【解决】
再次升级到最新的苹果系统 OS Sierra 10.12.1
【报错2】
configure: error: Cannot find libz
【试着解决】
执行 sudo brew install libz,继续报错:
【报错3】
Error: No available formula with the name "libz" ==> Searching for similarly named formulae... These similarly named formulae were found: libzdb libzip libzzip To install one of them, run (for example): brew install libzdb ==> Searching taps... Error: No formulae found in taps. ==> You haven't updated Homebrew in a while. A formula for libz might have been added recently. Run brew update to get the latest Homebrew updates!
按照提示,执行 brew update,继续报错:
【报错4】
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory [etc..] Error: update-report should not be called directly!
参考国外的网站,homebrew-error-update-report-should-not-be-called-directly
【解决】
1 cd /usr/local; git reset --hard origin/master; brew update 继续执行,brew update,继续报错:
【报错5】
Error: /usr/local must be writable!
执行 sudo brew update,继续报错:
【报错6】
Error: Cowardly refusing to 'sudo brew update' You can use brew with sudo, but only if the brew executable is owned by root. However, this is both not recommended and completely unsupported so do so at your own risk.
好吧,修改 /usr/local/ 文件夹的权限(用户)
sudo chown -R $(whoami) /usr/local
再次执行 brew update,这条语句没报错!
继续解决 Cannot find libz 的问题,执行: brew install libz,报错
【报错7】
Error: No available formula with the name "libz" ==> Searching for similarly named formulae... These similarly named formulae were found: libzdb libzip libzzip To install one of them, run (for example): brew install libzdb ==> Searching taps... Error: No formulae found in taps.
后来,找到一个帖子,Cannot find libz when install php56,找到解决方案
【解决】
执行
1 2 xcode-select --install brew upgrade PHP-5.6 继续执行,./configure ,没报错!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 ./configure --prefix=/usr/local/php/php-5.6 --with-config-file-path=/usr/local/php/php-5.6/etc --with-openssl=/usr/local/opt/openssl --with-zlib --with-bz2 --with-gd --with-jpeg-dir --with-png-dir --with-gettext --with-mhash --with-freetype-dir --with-mcrypt --with-iconv --with-curl --with-xmlrpc --with-mysql --with-pdo-mysql --with-mysqli --enable-calendar --enable-pdo --enable-zip --enable-mbstring --enable-mbregex --enable-bcmath --enable-soap --enable-sockets --enable-ftp --enable-gd-native-ttf --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-xml --enable-pcntl --enable-fpm --enable-opcache --without-pear PHP-7.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ./configure --prefix=/usr/local/php/php-7.0 --with-config-file-path=/usr/local/php/php-7.0/etc --with-openssl=/usr/local/opt/openssl --with-zlib --with-bz2 --with-gd --with-jpeg-dir --with-png-dir --with-gettext --with-mhash --with-freetype-dir --with-mcrypt --with-iconv --with-curl --with-xmlrpc --with-pdo-mysql --with-mysqli --enable-calendar --enable-pdo --enable-zip --enable-mbstring --enable-mbregex --enable-bcmath --enable-soap --enable-sockets --enable-ftp --enable-gd-native-ttf --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-xml --enable-pcntl --enable-fpm --enable-opcache --without-pear 执行 make 的时候会报错,参考 以前的文章,即可解决:
Mac Pro 编译安装 PHP 5.6.21 及 问题汇总
执行 make 操作的时候,又报错:
/usr/lib/libiconv.dylib /usr/local/lib/libiconv.dylib -o sapi/cli/php ld: can't write output file: sapi/cli/php for architecture x86_64
提示不能写入,应该是权限的问题,进入源码包的,查看文件 ./sapi/cli/php 文件,所属用户为 root,果然是权限问题,执行 make 的时候,sudo 一下,即 sudo make,大功告成