PHP + cURL: simple test script not working (on one machine)

I have the following a very simple PHP script that uses cURL to load a web page and to it display

<?php
  $ch = curl_init("http://www.reddit.com/");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
  $content = "Hello, World!";
  $content = curl_exec($ch);
  curl_close($ch); 
  echo $content;
?>

On my local machine, it works perfectly well — but not on my server machine. Here I get a “The connection was reset” error in Firefox. The line that causes trouble seems to be $content = curl_exec($ch);. If I comment this line, I get to see Hello, World! on both machines.

When calling phpinfo() on both machines, the cURL section looks pretty similar. What could be the problem here that it works on one machine but not on another. Basically, both run Ubuntu 14.04, with Apache 2 and PHP 5. What configurations or permissions might be different. I’m a bit at a loss where to look.

EDIT: As arkascha suggested, I’ve checked the Apache error.log file. And indeed, if I see the following error as soon as I execute the curl_exec command:

[core:notice] [pid 28267] AH00051: child pid 28274 exit signal Segmentation fault (11), possible coredump in /etc/apache2


Source: apache

Leave a Reply