简体   繁体   中英

Php file_get_contents and curl_exec dont work with external files

When i use file_get_contents or curl_exec with an url ( http://google.com or other) return false with different context, user_agent, etc... No errors no Warnings

With local files it works, example: file_get_contents("a.txt");

Configuration:

Php.ini is right: allow_url_fopen = On

No Firewall: sudo ufw status: inactive

Phpinfo():

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

Host: 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

It is a dedicated server, maybe is there a physical firewall? or something I can't control?

Thank you very much

Thank you all so much for your comments:

Does running wget or curl on the command line of that server work? – apokryfos

Exactly was a server error not a php issue, i just use the easy way to fix it:

After some minutes trying to find something wrong with resolv.conf,head,.d

Just use this solution if you didn't modify nothing manually and you don't have a customized resolv

.I've removed resolvconf:

aptitude purge resolvconf

And i installed it again:

apt-get install resolconf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM