2013-05-04 64 views
9

已經看到了同樣的問題 -​​ 但是,正如Jhilke Dai所說,它根本沒有解決,我同意。 在nginx + phpFPM安裝上有同樣的確切錯誤。當前的軟件版本:FreeBSd9.1上的nginx 1.2.8 php 5.4.13(cli)。實際上,它試圖通過phpMyadmin將大於3 MB的大文件導入到mysql中,實際上隔離了這個錯誤並確定它發生了。在達到30秒的限制時,還要計算後端關閉連接。 Nginx的錯誤日誌中拋出這個PHP-FPM - 上游過早關閉連接,同時讀取響應頭

[error] 49927#0: *196 upstream prematurely closed connection while reading response header from upstream, client: 7X.XX.X.6X, server: domain.com, request: "POST /php3/import.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/php5-fpm.sock2:", host: "domain.com", referrer: "http://domain.com/phpmyadmin/db_import.php?db=testdb&server=1&token=9ee45779dd53c45b7300545dd3113fed" 

我的php.ini限制相應提高試過

upload_max_filesize = 200M 
default_socket_timeout = 60 
max_execution_time = 600 
max_input_time = 600 

my.cnf中有關限制

max_allowed_packet = 512M 

FastCGI的限制

location ~ \.php$ { 
# fastcgi_split_path_info ^(.+\.php)(.*)$; 
fastcgi_pass unix:/tmp/php5-fpm.sock2; 
include fastcgi_params; 
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
fastcgi_param SCRIPT_NAME $fastcgi_script_name; 

fastcgi_intercept_errors on; 
fastcgi_ignore_client_abort on; 
fastcgi_connect_timeout 60s; 
fastcgi_send_timeout 200s; 
fastcgi_read_timeout 200s; 
fastcgi_buffer_size 128k; 
fastcgi_buffers 8 256k; 
fastcgi_busy_buffers_size 256k; 
fastcgi_temp_file_write_size 256k; 

改變fastcgi超時以及緩衝區大小,這沒有幫助。 PHP錯誤日誌不顯示問題,啓用所有通知,警告 - 沒有用。 也試過禁用APC - 沒有效果。

回答

0

你的腳本需要多長時間來計算?嘗試在PHP和Nginx HUGE超時中設置,並在請求期間監控您的系統。然後調整您的值以優化性能。

此外,降低PHP-FPM日誌級別,也許有一些類型的警告信息或調試跟蹤,可以給你一些信息。

最後,小心兒童和PHP-FPM可用進程數。也許Nginx正在捱餓,等待一個PHP-FPM孩子可用。

1

我有同樣的問題,得到了502網關錯誤頻繁和隨機在我的機器(OSX +的nginx + PHP-FPM),並通過改變/usr/local/etc/php/5.6/一些參數解決了它PHP-fpm.conf:

我有這樣的設置:

pm = dynamic 
pm.max_children = 10 
pm.start_servers = 3 
pm.max_spare_servers = 5 

...,並將其改爲:

pm = dynamic 
pm.max_children = 10 
pm.start_servers = 10 
pm.max_spare_servers = 10 

...,然後重新啓動的php-fpm的服務。

此設置基於我在此處找到的內容:[https://bugs.php.net/bug.php?id=63395]

相關問題