【问题标题】:Cannot compile PHP 5.6 with Homebrew on Mac OS 10.12无法在 Mac OS 10.12 上使用 Homebrew 编译 PHP 5.6
【发布时间】:2018-04-29 00:38:29
【问题描述】:

我在 Mac OS X 10.12 系统上使用 Brew 编译 PHP 5.6 时遇到问题。

我的问题开始了,因为即使我可以直接使用brew install php56 安装 PHP 5.6,问题是它没有使用正确的 php.ini 文件,应该取自 /usr/local/etc/php/5.6/php.ini,但似乎是来自/etc

m@MacBook-Pro-4.local:~$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

这是一个问题,因为我无法安装我需要的任何其他扩展,例如 php56-redis

所以我想从源代码构建 PHP 5.6,看看它是否能解决这个问题,但是当我开始构建时,我得到了这个错误,即使在谷歌上搜索后我也无法解决:

m@MacBook-Pro-4.local:~$ brew install php56 --build-from-source
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
kibana@5.6
==> Updated Formulae
kibana

==> Installing php56 from homebrew/php
==> Downloading https://php.net/get/php-5.6.32.tar.bz2/from/this/mirror
Already downloaded: /Users/mattia/Library/Caches/Homebrew/php56-5.6.32
==> ./configure --prefix=/usr/local/Cellar/php56/5.6.32_8 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/5.6 --with-config-file-path=/usr/local/etc/php/5.6 --with
Last 15 lines from /Users/mattia/Library/Logs/Homebrew/php56/01.configure:
checking for DSA_get_default_method in -lssl... no
checking for X509_free in -lcrypto... yes
checking for RAND_egd... no
checking for pkg-config... no
checking for OpenSSL version... >= 0.9.6
checking for CRYPTO_free in -lcrypto... yes
checking for SSL_CTX_set_ssl_version in -lssl... yes
checking for PCRE library to use... bundled
checking whether to enable the SQLite3 extension... yes
checking bundled sqlite3 library... yes
checking for ZLIB support... yes
checking if the location of ZLIB install directory is defined... no
checking for zlib version >= 1.2.0.4... 1.2.8
checking for gzgets in -lz... no
configure: error: ZLIB extension requires gzgets in zlib

我尝试在 Google 上搜索,但没有找到与 ZLIB extension requires gzgets in zlib 错误相关的任何内容。

我安装了最新版本的 XCode。

你能帮帮我吗?

【问题讨论】:

  • 你可以试试 php -v 看看运行的是哪个版本的 PHP 吗?
  • 我想我找到了问题所在。 “php”命令加载 /usr/bin/php 而不是 Homebrew 提供的 /usr/local/bin/php,但 /usr/local/bin 在我的 $PATH 中的 /usr/bin 之前你知道吗?
  • 这就是我的难处。您以前安装了 PHP。对吗?
  • 我想是的,但我不记得我何时以及如何安装它的。
  • 我的路径是“/Users/m/.rbenv/shims:/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin: /usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/m/.rvm/bin"

标签: php macos homebrew


【解决方案1】:

我认为你应该通过这种方式向系统指定PHP路径。

  1. 纳米 vim ~/.bash_profile

  2. 然后添加您当前的 PHP 路径(通过这种方式适用于 PHP 5.6)

    导出 PATH=/usr/local/etc/php/5.6/bin:$PATH

  3. 然后运行此命令保存并编译

    来源 ~/.bash_profile

【讨论】:

  • Homebrew 的 PHP 5.6 安装在 /usr/local/bin 中,在 /usr/bin 之前已经在我的 PATH 中。事实上,我的系统上没有 /usr/local/etc/php/5.6/bin 目录。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-09
  • 2013-06-18
  • 2019-07-20
  • 1970-01-01
  • 1970-01-01
  • 2016-06-11
  • 2013-08-12
相关资源
最近更新 更多