I'm trying to get the simpletest module for drupal to work, which relies on php-curl to fetch its requests.
When I as the user root do the following it works fine:
root@server:~# php -a
Interactive mode enabled
<?php
$ch = curl_init("http://testsite.drupal.dev/user");
$fp = fopen("example.html", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
root@server:~# cat /root/example.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Blah Blah -->
</body>
</html>
root@server:~#
However when the www-data user does it, it fails:
root@server:~# su - www-data
www-data@server:~$ php5 -a
Interactive mode enabled
<?php
$ch = curl_init("http://testsite.drupal.dev/user");
$fp = fopen("example.html", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
www-data@server:~$ cat example.html
www-data@server:~$
Has anyone seen this before? I'm struggling to see how I can fix this. Any help is appreciated! :)
Environment: Debian Etch / Apache2 / php5
Sorry. It wasn't a permissions issue. It turns out the www-data user had an old http_proxy set in its ~/.profile and in /etc/apache2/envvars that no longer exists.
I've commented it out and now its working :)