【问题标题】:Home Brew PHP 7.2.5 Install with cURLHome Brew PHP 7.2.5 使用 cURL 安装
【发布时间】:2018-10-19 22:57:42
【问题描述】:

我的 Mac 上有一个 localhost 开发环境,它使用自制软件的 php 公式,我正在努力尝试使用 cURL 的自定义路径安装,而不是使用默认的 Mac OS 版本 (v7.54.0) SSL 的安全传输。 SecureTransport 导致对远程服务的 SSL 请求出现很多问题,因此 OpenSSL 几乎是我的要求。

这是我到目前为止所采取的过程:

  1. 使用 OpenSSL 通过 home brew 安装 curl:brew install curl --with-openssl
  2. 编辑brew的php公式修改编译过程,告诉./configure使用brew安装的curl(v7.59.0)。我试过--with-curl=/usr/local/Cellar/curl/7.59.0--with-curl=#{Formula["curl"].opt_prefix}。第二个选项只是前者的动态符号链接。
  3. 保存编辑并从源代码重建 php:brew reinstall --build-from-source php

为了验证我是否有写入 ./configure 选项,我在我的 Brew 公式编辑中添加了一个临时行,该行会吐出通过的 args。如下所示:

--prefix=/usr/local/Cellar/php/7.2.5
--localstatedir=/usr/local/var
--sysconfdir=/usr/local/etc/php/7.2
--with-config-file-path=/usr/local/etc/php/7.2
--with-config-file-scan-dir=/usr/local/etc/php/7.2/conf.d
--with-pear=/usr/local/Cellar/php/7.2.5/share/php/pear
--enable-bcmath
--enable-calendar
--enable-dba
--enable-dtrace
--enable-exif
--enable-ftp
--enable-fpm
--enable-intl
--enable-mbregex
--enable-mbstring
--enable-mysqlnd
--enable-opcache-file
--enable-pcntl
--enable-phpdbg
--enable-phpdbg-webhelper
--enable-shmop
--enable-soap
--enable-sockets
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--enable-wddx
--enable-zip
--with-apxs2=/usr/local/opt/httpd/bin/apxs
--with-bz2
--with-curl=/usr/local/Cellar/curl/7.59.0
--with-fpm-user=_www
--with-fpm-group=_www
--with-freetype-dir=/usr/local/opt/freetype
--with-gd
--with-gettext=/usr/local/opt/gettext
--with-gmp=/usr/local/opt/gmp
--with-icu-dir=/usr/local/opt/icu4c
--with-jpeg-dir=/usr/local/opt/jpeg
--with-kerberos
--with-layout=GNU
--with-ldap
--with-ldap-sasl
--with-libedit
--with-libzip
--with-mhash
--with-mysql-sock=/tmp/mysql.sock
--with-mysqli=mysqlnd
--with-ndbm
--with-openssl=/usr/local/opt/openssl
--with-password-argon2=/usr/local/opt/argon2
--with-pdo-dblib=/usr/local/opt/freetds
--with-pdo-mysql=mysqlnd
--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc
--with-pdo-pgsql=/usr/local/opt/libpq
--with-pgsql=/usr/local/opt/libpq
--with-pic
--with-png-dir=/usr/local/opt/libpng
--with-pspell=/usr/local/opt/aspell
--with-sodium=/usr/local/opt/libsodium
--with-unixODBC=/usr/local/opt/unixodbc
--with-webp-dir=/usr/local/opt/webp
--with-xmlrpc
--with-xsl
--with-zlib

出于所有密集目的,这应该工作,但是当我从源重新安装php后打开phpinfo()时,我在配置命令下看到以下内容> 价值:

'./configure' 
'--prefix=/usr/local/Cellar/php/7.2.5' 
'--localstatedir=/usr/local/var' 
'--sysconfdir=/usr/local/etc/php/7.2' 
'--with-config-file-path=/usr/local/etc/php/7.2' 
'--with-config-file-scan-dir=/usr/local/etc/php/7.2/conf.d' 
'--with-pear=/usr/local/Cellar/php/7.2.5/share/php/pear' 
'--enable-bcmath' 
'--enable-calendar' 
'--enable-dba' 
'--enable-dtrace' 
'--enable-exif' 
'--enable-ftp' 
'--enable-fpm' 
'--enable-intl' 
'--enable-mbregex' 
'--enable-mbstring' 
'--enable-mysqlnd' 
'--enable-opcache-file' 
'--enable-pcntl' 
'--enable-phpdbg' 
'--enable-phpdbg-webhelper' 
'--enable-shmop' 
'--enable-soap' 
'--enable-sockets' 
'--enable-sysvmsg' 
'--enable-sysvsem' 
'--enable-sysvshm' 
'--enable-wddx' 
'--enable-zip' 
'--with-apxs2=/usr/local/opt/httpd/bin/apxs' 
'--with-bz2' 
'--with-fpm-user=_www' 
'--with-fpm-group=_www' 
'--with-freetype-dir=/usr/local/opt/freetype' 
'--with-gd' 
'--with-gettext=/usr/local/opt/gettext' 
'--with-gmp=/usr/local/opt/gmp' 
'--with-icu-dir=/usr/local/opt/icu4c' 
'--with-jpeg-dir=/usr/local/opt/jpeg' 
'--with-kerberos' 
'--with-layout=GNU' 
'--with-ldap' 
'--with-ldap-sasl' 
'--with-libedit' 
'--with-libzip' 
'--with-mhash' 
'--with-mysql-sock=/tmp/mysql.sock' 
'--with-mysqli=mysqlnd' 
'--with-ndbm' 
'--with-openssl=/usr/local/opt/openssl' 
'--with-password-argon2=/usr/local/opt/argon2' 
'--with-pdo-dblib=/usr/local/opt/freetds' 
'--with-pdo-mysql=mysqlnd' 
'--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' 
'--with-pdo-pgsql=/usr/local/opt/libpq' 
'--with-pgsql=/usr/local/opt/libpq' 
'--with-pic' 
'--with-png-dir=/usr/local/opt/libpng' 
'--with-pspell=/usr/local/opt/aspell' 
'--with-sodium=/usr/local/opt/libsodium' 
'--with-unixODBC=/usr/local/opt/unixodbc' 
'--with-webp-dir=/usr/local/opt/webp' 
'--with-xmlrpc' 
'--with-xsl' 
'--with-zlib' 
'--with-curl'

如果您注意到,在其尾部有一个尾随 --with-curl,而其他所有内容都按照 brew 公式中定义的顺序。我不知道它在哪里或如何附加到 ./configure 命令中,但这可能与问题的原因有关。

作为参考,这里是修改后的 Brew 公式 php.rb 的确切内容:

https://gist.github.com/Kevinlearynet/a44ffa2107a1b6e09935766a9e46cfd4

不管怎样,我完全被难住了。非常感谢任何帮助或帮助。

【问题讨论】:

  • 不确定它是否适合您的需求,但您是否尝试过安装 php —with-homebrew-curl
  • brew install php 现在是 homebrew-core 的一部分,该命令实际上已被删除,并且是这里问题的主要原因。以前当我安装了brew install php72 时,这是我采用的方法,但遗憾的是它不再可能了。
  • 与此处相关的另一条注释,我使用brew edit php 所做的编辑实际上是基于--with-homebrew-curl 在公式内部的更改基于此:github.com/Homebrew/homebrew-php/blob/…
  • 在 linux 中,问题是相同的。每个 7 版本都有自己的文件夹。您应该能够使用通配符搜索所有可用的槽:apt list php7* 或类似的 brew。
  • @Cryptopat 这并没有提供与我概述的问题相关的任何价值。我可以运行brew list | grep php 来执行此操作,但我得到的正是我所期望和想要看到的。问题是如何编译那个版本的 PHP。

标签: php macos curl homebrew


【解决方案1】:

我已经应用了dossy提供的补丁,它可以工作!

以下是解决问题的具体步骤。可以在下面找到有关此修复程序的更多详细信息。

  1. cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
  2. curl -s https://github.com/dossy/homebrew-core/commit/b75fe286f79e2b89548c5ed1bbe1958313c5c103.patch | patch -p1
  3. brew reinstall php --build-from-source

问题的具体来源似乎是需要libxml2 库来替换Mac 的内置libcurl,这最终迫使PHP 依赖SecureTransport。 php.rb 中的这两行是修复的关键部分:

  • depends_on "libxml2"
  • --with-libxml-dir=#{Formula["libxml2"].opt_prefix}

对于我的具体情况,我必须将我编辑的自制配方 (php.rb) 重置为源代码,因为我之前已经对其进行了编辑。结果,应用补丁一开始没有用。如果您还编辑了 php.rb 公式,那么我会将其重置为源:https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/php.rb

在 medium.com 上的链接文章中,dossy 建议在应用补丁后使用以下命令进行构建,brew install php --build-from-source。如果您已经安装了 PHP,则需要使用 reinstall 代替 install

【讨论】:

    猜你喜欢
    • 2016-11-27
    • 1970-01-01
    • 1970-01-01
    • 2021-06-10
    • 2011-09-22
    • 2023-01-20
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    相关资源
    最近更新 更多