我有 2 个服务器。服务器 1 具有引擎/api。服务器 2 有 apache2 和我的网站。
我尝试从网站对引擎做一个简单的 curl 。如果 curl 持续超过 ~15 秒,我会收到内部服务器错误。如果我从 bash(不使用浏览器)运行这个脚本,我会得到状态 200 和一个答案。当我从本地主机向引擎运行此脚本时,它运行正常。但是,当我想通过浏览器从我的服务器连接到引擎时 - 我在 15 秒后收到内部服务器错误。
我在 apache2 error_log 中没有任何信息。在 php.ini 中,我有执行时间 = 120,在 apache 中,我有 300 次超时。你知道哪里出了问题吗? (我的服务器在 debian lenny 下运行。)抱歉我的英语不好。
$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);
编辑
我做简单的脚本 php -
echo '1';
sleep(16);
echo '2';
但我也收到 500 错误。 我在 apache2 和 lighttpd 中尝试这个。 我很确定 - 这是系统上的错误配置...
编辑 问题解决了。问题是服务器磅的配置。感谢您的帮助。
最佳答案
仔细检查日志。要显示错误,请添加以下代码:
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);
关于php - Curl PHP - 奇怪的内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9790398/