2012-10-19 21 views
3

我想使用fastcgi_finish_request()函數。我的服務器上安裝了cpanel,PHP和Apache都是通過它配置的。由於我無法手動編輯apache或PHP(因爲cpanel),我在WHM中使用easyApache來構建它以獲取fastcgi。我看到一個選項caleld Mod FCGID,所以我檢查了它。使用該選項重新編譯PHP和apache後,我仍然在調用完成請求函數時調用未定義的函數。帶有fastcgi_finish_request()的PHP mod_fcgi;

回答

7

fastcgi_finish_requestPHP-FPM SAPI特定的功能,在無法使用標準的PHP-FCGI二進制(由阿帕奇[mod_fcgid,的mod_fastcgi],nginx的,lighttpd的等使用)。

+0

有沒有一個equivilent到mod_fcgi? –

+1

如果您僅限於cpanel功能,我懷疑您有任何事情可以做。如果你能夠編譯和添加php的擴展,http://php.net/manual/en/book.gearman.php可以用來安排作業和完成請求 –

9

有點晚了,但對人有好的信息。根據我使用PHP 5.5.7的經驗。使用php_mod(標準的Apache)

PHP

ob_start(); 
header("Connection: close\r\n"); 
header('Content-Encoding: none\r\n'); 

// your code here 

$size = ob_get_length(); 
header("Content-Length: ". $size . "\r\n"); 
// send info immediately and close connection 
ob_end_flush(); 
flush(); 

// run other process without the client attached. 

對於PHP使用FastCGI和PHP_FPM:

// your code here 

fastcgi_finish_request(); 

// run other process without the client attached. 

注意,對於我們來說,fastcgi_finish_request後()被執行,的log_error不再奏效。我認爲這是因爲與Apache的連接也被切斷,並且無法與fastCGI進行通信來記錄錯誤。

+0

嘗試了Apache的'Content-Length'技巧,但似乎沒有工作。 – COil