cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

curl not resolving via apache, but works via php command line

From: Ronald Lo <ron_at_activelogic.ca>
Date: Tue, 13 May 2008 21:06:43 -0700

Hello,

I am running: Gentoo with PHP Version 5.2.1 on a home webserver behind a
standard DLink router.
Curl is compiled in with the following info: libcurl/7.16.0
OpenSSL/0.9.8d zlib/1.2.3

I have a script that has the following code:

$ch = curl_init();
curl_setopt($ch,CURLOPT_HEADER,false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_URL,"www.google.ca");
$data = curl_exec($ch);
if (@curl_error($ch)) echo 'Error: '.curl_error($ch);
echo $data;
curl_close($ch);

When run from the command line I am able to get a proper response, and
the dns is resolved without a problem. I've done this with both my own
shell user account, as well as the apache user.
But, when running from a browser the request times out and I receive the
error: Error: Couldn't resolve host 'www.google.ca'

If I add the ip address and domain name my /etc/hosts file it resolves
fine via the web.

Any thoughts?

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-05-14