fopen失败,getaddrinfo失败 [英] fopen fails with getaddrinfo failed
问题描述
我在使用以下代码时遇到问题:
I am having problems with the following code:
function http_file_exists($url){
$f=fopen($url,"r");
if($f){
fclose($f);
return true;
} else {
return false;
}
} $ url ="http://www.minhemmelighed.dk/Graphics/Products/55.jpg";
} $url = "http://www.minhemmelighed.dk/Graphics/Products/55.jpg";
打印http_file_exists($ url);
print http_file_exists($url);
它返回的错误是:
警告:fopen():php_network_getaddresses:getaddrinfo失败:名称或服务在第6行的/srv/http/webshop3/image_scraper/test.php中未知警告:fopen(http://www.minhemmelighed.dk/Graphics/Products/55.jpg):无法打开流:php_network_getaddresses:getaddrinfo失败:名称或服务在第6行的/srv/http/webshop3/image_scraper/test.php中未知
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /srv/http/webshop3/image_scraper/test.php on line 6 Warning: fopen(http://www.minhemmelighed.dk/Graphics/Products/55.jpg): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /srv/http/webshop3/image_scraper/test.php on line 6
对此我该怎么办?我已经多次重启服务器.
What can I do about this? I have rebooted the server several times.
记录下来:
我可以通过浏览器访问有问题的网站
I can access the website in question through a browser
我正在Arch Linux上运行LAMP
I am running LAMP on Arch Linux
推荐答案
重新引导UNIX服务器极不可能解决问题.看来您需要检查服务器上的名称服务器配置.在Web服务器的控制台上(以php用户身份登录,可能是apache
或www-data
),进行测试
Rebooting a UNIX server is extremely unlikely to fix a problem. It looks like you need to check your nameserver configuration on the server. On the console of the web server (logged in as the php user, probably apache
or www-data
), test
dig www.minhemmelighed.dk
如果输出错误消息,请检查您的/etc/resolv.conf
.注释掉所有行并添加
If this outputs an error message, check your /etc/resolv.conf
. Comment out all lines and add
nameserver 8.8.8.8 # Google's public DNS server
如果这可以解决问题,请与原始名称服务器的管理员联系(或仅使用Google的8.8.8.8
).如果没有,请检查您的连接和防火墙.
If that solves the problem, contact the administrator of the original nameserver (or just use Google's 8.8.8.8
). If it doesn't, check your connectivity and firewalls.
这篇关于fopen失败,getaddrinfo失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!