Max*_*ard 9 php dnsmasq curl laravel laravel-valet
当我执行一个PHP脚本,该脚本运行一个URL到.test域的cURL请求时,该域在Mac上使用Laravel Valet / dnsmasq进行了设置,我得到此错误消息:
无法解析:mydomain.test(找不到域名)
当我在浏览器中测试域时,就可以了。
当我curl -Ik https://mydomain.test在终端中运行时,我获得了HTTP / 2 200代码,因此可以。
当我curl -k https://mydomain.test在终端中运行时,我得到了页面的源代码,因此可以。
为什么它不能与PHP中的cURL一起使用?我很绝望...
更新
由于受欢迎的需求;-)这是我的cURL代码。您不能做得更简单:
try {
$ch = curl_init( "http://mydomain.test" );
curl_exec( $ch );
dump(curl_error($ch));
curl_close( $ch );
} catch (Exception $e) {
var_dump($e);
}
Run Code Online (Sandbox Code Playgroud)
小智 25
此问题是由curl版本引起的,可以通过以下方式从终端检查curl版本吗?
curl --version 和 php --ri curl
运行时,php --ri curl您会看到cURL Information => 7.63.0此行。
然后,您可以比较您的版本,然后查看哪个curl版本不适用于dnsmasq。
我遇到了这个问题,我的curl版本是php中的7.64.0。
为解决该问题:
您可以卸载curl-openssl,此命令将删除curl-openssl的最新版本:
brew uninstall curl-openssl --ignore-dependencies
Run Code Online (Sandbox Code Playgroud)
Then restart php:
brew services restart php
Run Code Online (Sandbox Code Playgroud)
After restarting, php will see curl which is /usr/bin/curl and this version can access local domain.
添加127.0.0.1到我的 DNS 设置为我解决了这个问题。IESystem Preferences -> Network -> Advance -> DNS
并运行valet restart之后
| 归档时间: |
|
| 查看次数: |
1653 次 |
| 最近记录: |