Nginx上传模块nginx-upload-module安装和配置

本文详细介绍了如何在Linux环境中安装和配置Nginx上传模块nginx-upload-module。首先,通过yum安装必要的编译工具和库文件,然后下载并编译pcre库和Nginx源码。接着,将nginx-upload-module模块添加到Nginx配置中,并进行编译和安装。最后,展示了Nginx配置文件的部分内容,包括设置上传大小限制、启用断点续传以及定义上传后的处理路径等。
摘要由CSDN通过智能技术生成

Nginx上传模块nginx-upload-module安装和配置

安装编译工具及库文件

yum -y install make wget git zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

插件包准备

wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

tar zxvf pcre-8.35.tar.gz

git clone -b 2.2 https://github.com/vkholodkov/nginx-upload-module

安装Nginx

wget http://nginx.org/download/nginx-1.10.2.tar.gz

tar -zxvf nginx-1.10.2.tar.gz

cd nginx-1.10.2

./configure --prefix=/data/apps/nginx-upload \
    --pid-path=/data/logs/nginx-upload/nginx.pid \
    --lock-path=/data/apps/nginx-upload/nginx.lock \
    --error-log-path=/data/logs/nginx-upload/error.log \
    --http-log-path=/data/logs/nginx-upload/access.log \
    --http-client-body-temp-path=/data/temps/nginx-upload/client_body_temp \
    --http-proxy-temp-path=/data/temps/nginx-upload/proxy_temp \
    --http-fastcgi-temp-path=/data/temps/nginx-upload/fastcgi_temp \
    --http-uwsgi-temp-path=/data/temps/nginx-upload/uwsgi_temp \
    --http-scgi-temp-path=/data/temps/nginx-upload/scgi_temp \
    --with-http_stub_status_module \
    --with-http_ssl_module \
    --with-pcre=/data/software/pcre-8.35 \
    --add-module=/data/software/nginx-upload-module


make
make install

配置信息

user  root;
error_log  /data/logs/nginx-upload/error.log;
access_log  /data/logs/nginx-upload/access.log;
pid        /data/logs/nginx-upload/nginx.pid;

    server {
        client_max_body_size 100m;
        listen       80;
        # Enables resumable uploads.
        upload_resumable on;

        location ~/media/file/\S+/upload{
                upload_pass @fileUpload;
                upload_state_store /data/temps/upload_temp/upload_state;
                upload_store /data/temps/upload_temp/upload_tempfile;
                upload_set_form_field "name" "$upload_file_name";
                upload_set_form_field "content_type" "$upload_content_type";
                upload_set_form_field "path" "$upload_tmp_path";
                upload_aggregate_form_field "md5" "$upload_file_md5";
                upload_aggregate_form_field "size" "$upload_file_size";
                upload_pass_form_field "^submit$|^description$";
                upload_cleanup 400 404 499 500-505;
                upload_pass_args on;
        }
        
        location @fileUpload {
                proxy_pass http://127.0.0.1:8080;
        }
    }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

beyond阿亮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值