php - Home Brew PHP 7.2.5 使用 cURL 安装

标签 php macos curl homebrew

我的 Mac 上有一个本地主机开发环境,它使用 Homebrew 程序的 php 公式,我正在努力尝试使用 cURL 的自定义路径而不是默认的 Mac OS 版本 (v7 .54.0) 使用 SecureTransport for 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 }。第二个选项只是前者的动态符号链接(symbolic link)。
  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() 时,我在 < strong>配置命令值:

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

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

最佳答案

我已经应用了 dossy 提供的补丁并且它有效!

以下是解决问题的具体步骤。有关此修复内容的更多详细信息,请参见下文。

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

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

  • 依赖于“libxml2”
  • --with-libxml-dir=#{Formula["libxml2"].opt_prefix

对于我的具体情况,我不得不将我编辑过的 Homebrew 配方 (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

关于php - Home Brew PHP 7.2.5 使用 cURL 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50259893/

相关文章:

r - API 请求和curl::curl_fetch_memory(url, handle = handle) 中的错误:SSL 证书问题:证书已过期

php - 我怎样才能在我的 php 服务器上获得我的系统时区

php - SQL 注入(inject)不适用于 SQL 注入(inject)易受攻击的表单?

objective-c - 在 Cocoa 中解码整数和其他掩码

macos - 如何查找正在使用端口的java进程

debugging - 使用 CURL 调用时在 PhpStorm 中触发 xDebug

php - Google_Service_Directory - (403) 无权访问此资源/api

php - 检查两个id是否相同

stdlib cdefs.h 中的 C++ 错误?

php - 如何避免使用 PHP cURL 进行 URL 通配?