2013-06-26 293 views
1

我有一个在Kohana内置的网站,我试图允许Excel文件上传。我使用PHPExcel来读取数据。它在我的本地服务器上正常工作,但在远程服务器上失败。 (远程服务器在xmission.com托管)PHPExcel + Kohana:500内部服务器错误

所以在控制器中的代码如下:

public function action_bulk_upload() 
{ 
    if ($path = Kohana::find_file('vendor', 'PHPExcel')) { 
     require_once $path; 
    } 

    $objPHPExcel = PHPExcel_IOFactory::load($_FILES['upload']['tmp_name']);    
    $worksheet = $objPHPExcel->getActiveSheet(); 

    $range = range('A', 'Z'); 
    $data = array(); 
    $i  = 1; 

    while ($worksheet->cellExists('A' . $i)) { 
     $row = array(); 

     foreach ($range as $letter) { 
      if (!$worksheet->cellExists($letter . $i)) { 
       break; 
      } 

      $cell = $worksheet->getCell($letter . $i);  
      $row[] = $cell->getValue(); 
     } 

     $data[] = $row; 
     $i++; 
    } 

    $worksheet = null; 
    $objPHPExcel->disconnectWorksheets(); 
    $objPHPExcel = null; 

    $view = View::factory('content/admin/events/bulk_form') 
     ->bind('data', $data); 
    $this->add_content($view); 

    // The code gets here 
} 

该代码使得它所有的方式通过控制器但不幸的是我得到了500内部服务器错误。错误日志说:

[Wed Jun 26 12:45:08 2013] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error. 
[Wed Jun 26 12:45:08 2013] [warn] (104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request function 

这听起来我想我需要改变FastCGI设置,但它是一个共享的托管帐户,所以我没有可能能。谢谢您的帮助!

回答

2

默认情况下,FastCGI在500次请求后处理退出。您可以提高PHP_FCGI_MAX_REQUESTS(在包装中)或将FcgidMaxRequestsPerProcess限制为500。

我不认为你可以在不修改FastCGI配置的情况下解决这个问题,但我可能错了。

http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#examples

+0

那么什么构成一个请求?它是一个用户访问一个页面= 1的请求吗?或者1 php脚本可以使用多个请求? – chrislondon

+0

@chrislondon:查看http://stackoverflow.com/questions/708670/ –

1

我说要么你的文件过大或脚本超过最高。执行时间处理时间。在调用你的函数之前试试这个代码:

ini_set('max_execution_time', 0); // No time limit 
ini_set('post_max_size', 20M); 
ini_set('upload_max_filesize', 20M);