使用 nginx_upload_module 上传文件

使用 nginx_upload_module上传大附件

由于PHP会上传超时,不能限速!

php.ini中的配置对nginx_upload_module没有影响。

如果要上传大文件,可以在nginx.conf中的http部分添加一行:

client_max_body_size 50m;

另外还要进行上传的配置:

location = /suibian-shezhi.htm {

                upload_pass   @utest; 

 

                upload_store /tmp/nginx_upload;

 

                upload_store_access user:rw;

 

                upload_set_form_field "${upload_field_name}_name" $upload_file_name;

                upload_set_form_field "${upload_field_name}_content_type" $upload_content_type;

                upload_set_form_field "${upload_field_name}_path" $upload_tmp_path;

 

                upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5;

                upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size;

 

                upload_pass_form_field "^.*$";

 

                #upload_limit_rate 1000k; (用于限速)

 

                upload_cleanup 400 404 499 500-505;

        }

        location @utest{

                rewrite ^(.*)$ /index.php last;

        }

 

 如何安装:

之前已安装nginx但没有装这个module

重新安装过。

1.下载nginx wget http://nginx.org/download/nginx-1.3.0.tar.gz

2, 下载nginx upload module模块

wget http://www.grid.net.ru/nginx/download/nginx_upload_module-2.2.0.tar.gz

3. 解压缩nginx_upload_module 这个解压就可以了,不需要安装什么的

4. ./configure --prefix=.... --add-module=../nginx_upload_module-2.2.0/

注意要添加--add-module 可以是相对路径,也可以是绝对路径

 

 

相关配置:

注意:需要修改php.ini以下参数

file_uploads on 是否允许通过http上传

upload_max_filesize 8m 允许上传文件的最大大小

post_max_size 8m 通过表单POST给php所能接收的最大值

另外nginx.conf中设置上传文件大小

upload_max_file_size 软限制

 

client_max_body_size 硬限制

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值