PHP在NGINX以FAST-CGI方式运行上传大文件时的参数配置
首先要用PHP 生成临时文件,然后在上传到FTP服务器。
1.PHP配置文件PHP.INI
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir =/tmp
; Maximum allowed size for uploaded files.
upload_max_filesize = 30M
; Maximum size of POST data that PHP will accept.
post_max_size = 30M
2.NGINX配置
client_max_body_size 30m;
PHP程序的执行时间超过了NGINX的等待时间,可以增加nginx.conf配置文件中FastCGI的timeout时间:
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
3.PHP-FPM配置
在 php.ini 中,参数 max_execution_time设置 PHP 脚本的最大执行时间,在 php-cgi 中,真正能够控制 PHP 脚本最大执行时间的是php-fpm.conf配置文件中的以下参数:
php-fpm.conf
The timeout (in seconds) for serving a single request after which the worker process will be terminated Should be used when 'max_execution_time' ini option does not stop script execution for some reason.
'0s' means 'off'
<value name="request_terminate_timeout">0s</value>
|