52AV手機A片王|52AV.ONE

標題: PHP上傳檔案的限制與修改 [打印本頁]

作者: IT_man    時間: 2015-10-16 17:35
標題: PHP上傳檔案的限制與修改
[1]  vi /etc/php.ini, e. C/ P  }7 c$ V
% x9 V$ ~4 I  C, q& m$ {
max_execution_time = 300     Script執行時間上限(單位:秒); F' i. K2 t" H; A7 i

: M& ]# [/ u) ~8 Hmax_input_time = 300   Script處理資料時間上限(單位:秒)
' t$ ?% V' h) B7 D
0 [& d! ?2 A/ H. imemory_limit = 2001M   系統記憶體(注意,這個的值一定要設比下面兩項的值都大)
) \& N( c4 T, y. A2 _" f! b6 A1 C9 B5 _
post_max_size = 200M   使用表單的file欄位時是用POST傳值(最主要2)
3 ]3 w/ r& p6 t  c# P6 N' _4 [" G2 V/ T

4 ~, O( c# p, b* w+ a* n9 `! [upload_max_filesize = 2000M   單次上傳檔案容量(最主要1)' Q1 r# N. {3 U* ]
( _) M* Y5 L2 w! a0 v1 a* l3 [
default_socket_timeout = 300   Socket無回應斷線時間(單位:秒). J8 H7 F% Q" ^
& p/ D$ E4 ]2 l
[2]  vi /etc/nginx/nginx.conf: u4 k7 e: U  v9 L

# q% x# L6 u2 v& R/ Y: `client_max_body_size 2500M;client_body_buffer_size 2500M;6 C, I( o* P' C0 L# G5 V, e& z

3 g: _) }( ^' e7 h) K+ {5 [8 }[3]  更改 /etc/nginx/conf.d/ 欲加大上傳檔案之網站的設定檔  , Ex: av4u.info.conf
3 g/ K0 c* ~; jclient_max_body_size 2500m;7 M6 r# p" E4 p" X; |
client_body_buffer_size 2500m;+ Q$ c4 g7 ]( z% n/ {- R( t' |
0 u& H  H# z3 f( l' {

% t' c( m$ W5 j4 ]
[4] vi /etc/php-fpm.d/www.conf: P2 v4 v% W# k
request_terminate_timeout  = 0   (default value = 0) 重要
# u/ a" F4 m' {  A! q
以前的經驗設為60s , 當上傳 5G 以上的大小上傳完成再經過60s後就出現 "502 bad gateway",經查 /var/log/nginx/下的相關 error log 發現:
! S1 b# O  D0 r. ]*1138927 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: xxx.xxx.xxx.xxx , 後省略
1 g, B- a% c/ S( [2 J. v
- c0 n- w& C3 ]; N( y& k" G0 u[5]
. j3 |2 R' F5 ]" n  H8 G- B! Rservice php-fpm restart
# v# x8 Z/ r  t3 {7 n5 x& b' W: w/ D  S- Bservice nginx restart
4 A7 w- a% _& s7 n, l& ]' ^3 e1 N7 u! s4 t4 Y& e( C# e

2 N0 @/ \: d, f1 H* Q; ]/ z; n9 F% a
+ h+ C5 H6 b# P: g( u1 n1 K/ G7 q3 Y9 T3 m
0 k! t: e3 ]. z7 G9 {9 P4 _

# _4 q3 j8 Z0 E- ]4 K) R/ W& Y1 ?





歡迎光臨 52AV手機A片王|52AV.ONE (https://www.itech.casa/) Powered by Discuz! X3.2