macbook pro的升级php,记 MacBook Pro 系统升级后,编译安装 PHP-5.6.28 / PHP-7.0 报错修复过程...

买 Mac Pro 的时候,系统为 OS X 10.11.5,编译 PHP-5.6.21 的时候,也遇到一些坑,安装过程记录如下:

后来,系统升级为 OS X 10.11.6,再后来,打算升级  PHP 至 5.6.28,报错:

【报错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!

【解决】

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.

【解决】

执行

xcode-select --install

brew upgrade

PHP-5.6 继续执行,./configure ,没报错!

./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

./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 的时候会报错,参考 以前的文章,即可解决:

执行 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,大功告成。

按照同样的方式,编译安装了 PHP-7.0,并实现了 PHP 多版本的 共存 和 切换

延伸阅读:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值