当前位置: 首页 » 产品 » 新闻资讯 » 正文

nginx安装文件上传ngx_upload模块教程

放大字体  缩小字体 发布日期: 2024-10-02 18:27   来源:http://www.baidu.com/  作者:无忧资讯  浏览次数:23
核心提示:  ngx_upload模块是nginx中一个文件上传模式了,下面我们来看看nginx安装文件上传ngx_upload模块步骤,希望例子对各位有帮助.

  ngx_upload模块是nginx中一个文件上传模式了,下面我们来看看nginx安装文件上传ngx_upload模块步骤,希望例子对各位有帮助.

  安装nginx,并加入nginx upload module和nginx cache purge module:

  mkdir ~/download

  cd ~/download

  wget

  tar zxf nginx_upload_module-2.0.12.tar.gz

  git clone https://github.com/FRiCKLE/ngx_cache_purge.git

  yum groupinstall "Development Tools"

  yum install pcre-devel zlib-devel openssl-devel

  wget

  tar zxf nginx-1.2.3.tar.gz

  cd nginx-1.2.3

  http://www.jsgho.com/help/fwq/configure --prefix=http://www.3lian.com/usr/local/nginx --with-pcre --with-http_ssl_module --add-module=http://www.jsgho.com/help/nginx_upload_module-2.0.12 --add-module=http://www.jsgho.com/help/ngx_cache_purge

  make && make install

  尝试启动:

  /usr/local/nginx/sbin/nginx

  ps aux | grep nginx

  假如我的网站是放在 /home/mysite/www 下的,而nginx配置文件就放在 /home/mysite/etc 下:

  省略了很多内容的配置文件,mysite.conf:

  server {

  listen 80;

  server_name 192.168.1.123;

  client_max_body_size 20M;

  location /upload {

  include /home/mysite/etc/nginx/ngx_upload.conf;

  }

  ....其他的配置....

  location @after_upload {

  proxy_pass ;

  }

  }

  将nginx_upload.conf独立开来,是因为其他网站也可以包含此上传配置文件:

  nginx_upload.conf:

  upload_pass @after_upload;

  upload_pass_args on;

  upload_cleanup 400 404 499 500-505;

  upload_store /home/mysite/www/uploads/tmp;

  upload_store_access user:r;

  upload_limit_rate 128k;

  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_pass_form_field,代表可以将表单的所有参数保持原样传递到后端,需要区分文件保存类型时很有用。

 
 
[ 产品搜索 ]  [ 加入收藏 ]  [ 告诉好友 ]  [ 打印本文 ]  [ 违规举报 ]  [ 关闭窗口 ]

 

 
推荐图文
推荐产品
点击排行
    行业协会  备案信息  可信网站