curl-users
Curl works in command-line but not on web...
Date: Fri, 6 Oct 2006 10:51:33 +0200
This problem is now haunting me!
To recap!
I have Fedora Core 5 with Apache 2.2.2, PHP 5.1.4 and MySQL 5.0.22
I have the following PHP extensions installed:
libxml, xml, wddx, tokenizer, sysvshm, sysvsem, sysvmsg, standard,
SimpleXML, sockets, SPL, shmop, session, Reflection, pspell, posix,
mime_magic, iconv, hash, gmp, gettext, ftp, exif, date, curl, ctype,
calendar, bz2, zlib, pcre, openssl, apache2handler, gd, imap, mbstring,
mysql, mysqli, PDO, pdo_mysql, pdo_sqlite
Curl is 7.15.5 and reports enabled:
curl 7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8a zlib/1.2.3
libidn/0.6.2
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
Curl from the command-line works just fine, but the following test page:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.dk/");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1)');
$result = curl_exec($ch);
echo '<pre>INFO';
print_r(curl_getinfo($ch));
echo '</pre>';
echo '<pre>RESULT';
print htmlentities($result);
echo '</pre>';
echo '<pre>CURLERR';
echo curl_errno($ch) . ' ' . curl_error($ch);
echo '</pre>';
echo '<pre>CURLVERSION';
echo curl_version();
echo '</pre>';
curl_close($ch);
?>
Gives this output:
INFOArray
(
[url] => http://www.google.dk/
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0.002049
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0
)
RESULT
CURLERR7 Failed to connect to 64.233.183.104: Permission denied
CURLVERSIONArray
A command-line request as root for the same page gives:
<html><head><meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1"><title>Google</title><style><!--
body,td,a,p,.h{font-family:arial,sans-serif}
.h{font-size:20px}
.q{color:#00c}
--></style>
<script>
<!--
function sf(){document.f.q.focus();}
// -->
</script>
</head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b
alink=#ff0000 onLoad=sf() topmargin=3 marginheight=3><center><table border=0
cellspacing=0 cellpadding=0 width=100%><tr><td align=right nowrap><font
size=-1><a href="/url?sa=p&pref=ig&pval=3&q=
http://www.google.dk/ig%3Fhl%3Dda&sig=__fNfWHueYNoIs696ThtRm5eymkqY=">Personlig
startside</a> | <a href="
https://www.google.com/accounts/Login?continue=http://www.google.dk/&hl=da">Log
ind</a></font></td></tr><tr height=4><td><img alt="" width=1
height=1></td></tr></table><table cellpadding=0 cellspacing=0
border=0><tr><td align=right valign=bottom><img src=images/hp0.gif width=158
height=78 alt="Google"></td><td valign=bottom><img src=images/hp1.gif
width=50 height=78 alt=""></td><td valign=bottom><img src=images/hp2.gif
width=68 height=78 alt=""></td></tr><tr><td class=h align=right
valign=top><b></b></td><td valign=top><img src=images/hp3.gif width=50
height=32 alt=""></td><td valign=top class=h><font color=#6f6f6f
style=font-size:16px><b>Danmark</b></font></td></tr></table><br>
<form action=/search name=f><table border=0 cellspacing=0
cellpadding=4><tr><td nowrap><font
size=-1><b>Nettet</b> <a class=q
href="/imghp?hl=da&ie=UTF-8&tab=wi">Billeder</a> <a
class=q href="http://groups.google.dk/grphp?hl=da&ie=UTF-8&tab=wg">Grupper</a> <a
class=q
href="/dirhp?hl=da&ie=UTF-8&tab=wd">Indeks</a> </font></td></tr></table><table
cellspacing=0 cellpadding=0><tr><td width=25%> </td><td
align=center><input type=hidden name=hl value=da><input type=hidden name=ie
value="ISO-8859-1"><input maxlength=2048 size=55 name=q value=""
title="Google-søgning"><br><input type=submit value="Google-søgning"
name=btnG><input type=submit value="Jeg føler mig heldig" name=btnI></td><td
valign=top nowrap width=25%><font size=-2> <a
href=/advanced_search?hl=da>Avanceret søgning</a><br> <a
href=/preferences?hl=da>Indstillinger</a><br> <a
href=/language_tools?hl=da>Sprogværktøjer</a></font></td></tr><tr><td
colspan=3 align=center><font size=-1>Søg: <input id=all type=radio name=meta
value="" checked><label for=all> på nettet </label><input id=lgr type=radio
name=meta value="lr=lang_da" ><label for=lgr> sider på dansk </label><input
id=cty type=radio name=meta value="cr=countryDK" ><label for=cty> sider fra
Danmark </label></font></td></tr></table></form><br><font
size=-1>Google.dkpå: <a href="
http://www.google.dk/fo">Føroyskt</a> </font><br><br><br><font size=-1><a
href="/ads/">Annonceringsprogrammer</a> - <a href=/intl/da/about.html>Alt om
Google</a> - <a href=http://www.google.com/ncr>Google.com in
English</a></font><p><font size=-2>©2006
Google</font></p></center></body></html>
People are saying that it is something with the OS setup and maybe firewall,
but turning of the firewall doesn't help. And I'm out of ideas on what kind
of php or httpd settings I should try.
-- Rune Fjellheim Executive Secretary Arctic Council - Indigenous Peoples' Secretariat P.O. Box 2151, Strandgade 91, 4. Sal DK-1016 Copenhagen K, Denmark Tel: +45 32 83 37 94 Mob:+45 40 17 02 93 Fax: +45 32 83 37 91 - www.arcticpeoples.org - rune.fjellheim_at_arcticpeoples.org rf_at_ghsdk.dk SkypeID: daikosReceived on 2006-10-06