PHP php_network_getaddresses: getaddrinfo failed: No such host is known
Your "localhost" cannot resolve the name www.google.com, which means your machine doesn't/can't reach a valid dns server.
Try ping google.com on the console of that machine to verify this.
IMO it's the different way to resolve a name from the OS and PHP.
Try:
echo gethostbyname("host.name.tld");
and
var_export (dns_get_record ( "host.name.tld") );
or
$dns=array("8.8.8.8","8.8.4.4");
var_export (dns_get_record ( "host.name.tld" , DNS_ALL , $dns ));
You should found some DNS/resolver error.