Home Brew PHP 7.2.5 使用 cURL 安装

Kev*_*ary 5 php macos homebrew curl

我的 Mac 上有一个 localhost 开发环境,它使用自制软件的php公式,我正在尝试使用 cURL 的自定义路径进行安装,而不是使用 SecureTransport for SSL 的默认 Mac OS 版本 (v7.54.0)。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
Run Code Online (Sandbox Code Playgroud)

从所有密集目的来看,这应该是有效的,但是当我phpinfo()从源代码重新安装 php 后打开一个时,我在配置命令值下看到以下内容:

'./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'
Run Code Online (Sandbox Code Playgroud)

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

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

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

无论哪种方式,我都完全被难住了。非常感谢任何帮助或帮助。

Kev*_*ary 4

我已经应用了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 中的这两行是针对我的目的进行修复的关键部分:

  • 取决于“libxml2”
  • --with-libxml-dir=#{公式["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,则需要使用重新安装来代替安装