Home >Backend Development >PHP Tutorial >PHP curl 无法解析域名

PHP curl 无法解析域名

WBOY
WBOYOriginal
2016-06-06 20:33:081806browse

LNMP,DNS设置无误,curl任意地址报错:

<code>Couldn't resolve host 'example.com'
</code>

file_get_contents 报错:

<code>Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known
</code>
  1. shell 中直接 curl -I http://example.com 正常,ping也正常
  2. curl设置 CURL_IPRESOLVE_V4 无效

回复内容:

LNMP,DNS设置无误,curl任意地址报错:

<code>Couldn't resolve host 'example.com'
</code>

file_get_contents 报错:

<code>Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known
</code>
  1. shell 中直接 curl -I http://example.com 正常,ping也正常
  2. curl设置 CURL_IPRESOLVE_V4 无效

我有一个疑问,你的 example.com换成你具体需要的域名没有。有时候,运营商的DNS服务器可能没有对应的ip地址映射关系,从而找不到网站的。

好吧...找到问题了,PHP运行在chroot环境中,关掉就好了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn