If I run
php -r 'print_r(file_get_contents("http://mirror.facebook.net/centos/timestamp.txt"));'
I get "Tue Oct 28 13:24:01 UTC 2014" (as expected).
But if I have a php file:
<?php
print_r(file_get_contents("http://mirror.facebook.net/centos/timestamp.txt"));
It gives me:
**Warning:** file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known ...
**Warning:** file_get_contents(http://mirror.facebook.net/centos/timestamp.txt): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known ...
What is the difference between "php -r" and php running the code out of a file
UPDATE
This is not the answer to the question but it did solve my problem so for the sake of future googlers: I don't know which of these two solutions was the key but it was working when I restarted apache.
In resolv.conf set
nameserver 8.8.8.8
(which had my router's address)There's an SELinux boolean
httpd_can_network_connect
which must be turned on:
setsebool -P httpd_can_network_connect 1