Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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 :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.