配置nginx php上传大文件

配置nginx php上传大文件:

1. 修改PHP配置文件中的三项:vim /usr/local/php/etc/php.ini

1.file_uploads 
设为On,允许通过HTTP上传文件 

2.upload_tmp_dir 
文件上传至服务器时用于临时存储的目录,如果没指定,系统会使用默认的临时文件夹(我的机器是/tmp)。 

3.upload_max_filesize 
允许上传文件大小的最大值,默认为2M。 

4.post_max_size 
Php可接收的post数据的最大值(包括表单里的所有值的总合),默认为8M。 

5.memory_limit 
每个php所最占的最大内存数,这个值要大于允许上传的文件大小。 

6.max_execution_time 
每个php运行的最长时间(秒),默认30秒。 

7.max_input_time 
Php解析POST/GET数据的最长时间(秒),默认60秒。This sets the maximum time in seconds a scripts is allowed to parse input data, like POST and GET.It is measured from the mement of receiving all data on the server to the start of script execution.

2. 修改Nginx配置文件:vim /usr/local/nginx/conf/nginx.conf (如果忘了配置文件的具体位置,可以使用 locate nginx.conf 查找)

  (1)client_max_body_size 500m   #客户端最大上传大小 500M

3. 重启PHP:/etc/init.d/php-fpm restart

4. 平滑重启Nginx:/usr/local/nginx/sbin/nginx -s reload

1. 修改PHP配置文件中的三项:vim /usr/local/php/etc/php.ini

1.file_uploads 
设为On,允许通过HTTP上传文件 

2.upload_tmp_dir 
文件上传至服务器时用于临时存储的目录,如果没指定,系统会使用默认的临时文件夹(我的机器是/tmp)。 

3.upload_max_filesize 
允许上传文件大小的最大值,默认为2M。 

4.post_max_size 
Php可接收的post数据的最大值(包括表单里的所有值的总合),默认为8M。 

5.memory_limit 
每个php所最占的最大内存数,这个值要大于允许上传的文件大小。 

6.max_execution_time 
每个php运行的最长时间(秒),默认30秒。 

7.max_input_time 
Php解析POST/GET数据的最长时间(秒),默认60秒。This sets the maximum time in seconds a scripts is allowed to parse input data, like POST and GET.It is measured from the mement of receiving all data on the server to the start of script execution.

2. 修改Nginx配置文件:vim /usr/local/nginx/conf/nginx.conf (如果忘了配置文件的具体位置,可以使用 locate nginx.conf 查找)

  (1)client_max_body_size 500m   #客户端最大上传大小 500M

3. 重启PHP:/etc/init.d/php-fpm restart

4. 平滑重启Nginx:/usr/local/nginx/sbin/nginx -s reload

猜你喜欢

转载自www.cnblogs.com/sunsky303/p/9359865.html