Curl PHP - strange internal server error
I have 2 servers. Server 1 has engine / api. Server 2 has apache2 and my site.
From the website I am trying to do a simple curl to the engine. If the curl lasts more than ~ 15 seconds, I get an internal server error. If I run this script from bash (not using a browser) I get a 200 status and a response. When I run this script from localhost to the engine it works fine. But, when I want to connect from my server through the browser to the engine, I get an internal server error after 15 seconds.
I have no information in apache2 error_log. In php.ini I have runtime = 120 and in apache I have 300 timeouts. Do you know what's wrong? (My server is running debian lenny.) Sorry for my bad english.
$data = "Test text";
$_data['post'] = 'source_text='.urlencode($data);
$_data['url'] = ENGINE_PATH;
$_data['access'] = HTACCESS_LOGIN.':'.HTACCESS_PASSWORD;
$_curl = curl_init();
if(!empty($_data['post'])){
curl_setopt($_curl, CURLOPT_POST, 1);
curl_setopt($_curl, CURLOPT_POSTFIELDS, $_data['post']);
}
if(substr($_data['url'],0,5) == 'https'){
curl_setopt( $_curl, CURLOPT_SSL_VERIFYPEER, false );
}
curl_setopt($_curl, CURLOPT_URL, $_data['url']);
curl_setopt($_curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($_curl, CURLOPT_TIMEOUT, 60);
curl_setopt($_curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($_curl, CURLOPT_HEADER, 0);
curl_setopt($_curl, CURLOPT_FOLLOWLOCATION, 1);
if(!empty($_data['access'])){
curl_setopt( $_curl, CURLOPT_USERPWD, $_data['access']);
}
$agent = 'Mozilla/5.0 (X11; U; Linux x86_64; pl-PL; rv:1.9.2.22) Gecko/20110905 Ubuntu/10.04 (lucid) Firefox/3.6.22';
if(!empty($_SERVER['HTTP_USER_AGENT'])){
$agent = $_SERVER['HTTP_USER_AGENT'];
}
curl_setopt($_curl, CURLOPT_USERAGENT, $agent);
curl_setopt($_curl, CURLOPT_FAILONERROR, 1);
$data = curl_exec($_curl);
EDIT
I am doing a simple php script -
echo '1';
sleep(16);
echo '2';
But I am getting 500 errors too. I am trying this in apache2 and lighttpd. What I'm sure is a configuration error on the system ...
EDIT Problem solved. The problem was the server pound configuration. Thank you for your help.
source to share
Check the logs carefully. Add the following code to display the error:
ini_set('error_reporting', E_ALL);
error_reporting(E_ALL);
ini_set('log_errors', true);
ini_set('html_errors', false);
ini_set('error_log', dirname(__FILE__).'script_error.log');
ini_set('display_errors', true);
source to share