无法在Mac OS 10.12上使用Homebrew编译PHP 5.6

时间:2017-11-15 17:05:41

标签: php macos homebrew

我在使用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以查看它是否能解决这个问题,但是当我开始构建时,我得到了这个错误,即使在Google上搜索后我也无法解决:

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。

你能帮我吗?

1 个答案:

答案 0 :(得分:0)

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

  1. nano vim~ / .bash_profile

  2. 然后添加当前的PHP路径(以这种方式为PHP 5.6)

    export PATH = / usr / local / etc / php / 5.6 / bin:$ PATH

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

    source~ / .bash_profile