简体   繁体   English

卷曲PHP - 奇怪的内部服务器错误

[英]Curl PHP - strange internal server error

I have 2 servers. 我有2台服务器。 Server 1 has the engine/api. 服务器1具有引擎/ api。 Server 2 has apache2 and my website. 服务器2有apache2和我的网站。

From the website I try do a simple curl to the engine. 从网站上我尝试对引擎做一个简单的卷曲。 If the curl lasts more than ~15sec I get internal server error. 如果卷曲持续超过15秒,我会收到内部服务器错误。 If I run this script from bash (not using a browser) I get status 200 and an answer. 如果我从bash(不使用浏览器)运行此脚本,我会得到状态200和答案。 When I run this script from localhost to the engine it runs ok. 当我从localhost运行此脚本到引擎时,它运行正常。 But, when I want connect from my server via browser to engine - I get the internal server error after 15s. 但是,当我想从我的服务器通过浏览器连接到引擎 - 我在15秒后得到内部服务器错误。

I don't have any information in apache2 error_log. 我在apache2 error_log中没有任何信息。 In php.ini I have the execution time = 120 and in apache I have 300 timeout. 在php.ini中,我有执行时间= 120,在apache中我有300超时。 Do you have any idea what is wrong? 你知道什么是错的吗? (My server runs under debian lenny.) Sorry for my bad English. (我的服务器在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);

EDIT 编辑

I do simple script php - 我做简单的脚本php -

 echo '1';
 sleep(16);
 echo '2';

But I get 500 error too. 但我也得到500错误。 I try this in apache2 and lighttpd. 我在apache2和lighttpd中尝试这个。 Than I pretty sure - this is error configuration on system... 我非常肯定 - 这是系统上的错误配置......

EDIT Problem is solved. 编辑问题解决了。 The problem was configuration of server pound. 问题是服务器磅的配置。 Thank you for help. 谢谢你的帮助。

Carefully check the logs. 仔细检查日志。 To display the error, add the following code: 要显示错误,请添加以下代码:

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

Ensure that max_execution_time is defined properly using phpinfo() . 确保使用phpinfo()正确定义max_execution_time

Or try using set_time_limit() . 或者尝试使用set_time_limit()

<?php
// run indefinitely
set_time_limit(0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM