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

PHP curl 无法解析域名

WBOY
Release: 2016-06-06 20:33:08
Original
1806 people have browsed it

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

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

file_get_contents 报错:

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

回复内容:

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

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

file_get_contents 报错:

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

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template