Php file_get_contents和curl_exec不能处理外部文件


Php file_get_contents and curl_exec dont work with external files

当我使用file_get_contents或curl_exec与url (http://google.com或其他)返回false与不同的上下文,user_agent等…无错误无警告

对于本地文件,它可以工作,例如:file_get_contents("a.txt");

配置:

Php.ini是正确的allow_url_fopen = On

否Firewall: sudo ufw status: inactive

Phpinfo ():

协议:dict、file、ftp、ftps、gopher、http、https、imap、imaps、ldap、ldaps、pop3、pop3s、rtmp、rtsp、smtp、smtps、telnet、tftp

主持人:x86_64-pc-linux-gnu

SSL: Version OpenSSL/1.0.1e

OpenSSL: support enabled

OpenSSL: Library Version OpenSSL 1.0.1e 11 Feb 2013

OpenSSL: Header Version OpenSSL 1.0.1e 11 Feb 2013

这是一个专用服务器,也许有物理防火墙?还是我无法控制的事情?

非常感谢

非常感谢大家的评论:

在该服务器的命令行上运行wget或curl是否有效?–apokryfos

完全是一个服务器错误不是php的问题,我只是用简单的方法来修复它:

几分钟后试图找到一些错误的resolv.conf,头,。d

如果您没有手动修改任何内容并且没有自定义分辨率,请使用此解决方案

。我已经删除了resolvconf:

aptitude purge resolvconf

我重新安装了它:

apt-get install resolconf