nginx 如何安装 nginx upload 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
解压

安装之前,也许需要安装 pcre
yum install pcre-devel


3,在nginx的解压目录下运行
./configure --prefix=/root/nginx --add-module=../nginx_upload_module-2.2.0/

--add-module 可以是相对路径,也可以是绝对路径, --prefix 安装的目录,一定要存在

4,make


5,   make install


6, nginx 配置参考文件 :包括thin的配置
user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
	upload_resumable on;
        client_max_body_size 100m;
        listen       8888;
        server_name  localhost;
        # Upload form should be submitted to this location
        location /upload {
          # Pass altered request body to this location
          upload_pass   @test;
          upload_store /tmp 1;
        
          upload_store_access user:r;

          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 "^submit$|^description$";
          upload_cleanup 400 404 499 500-505;
    }

    # Pass altered request body to a backend
    location @test {
        proxy_pass   http://mongrel;
    }
 
    }
   
   server{
     listen 30091;
     root /var/www/sms/public/video;
   }

   upstream mongrel {
     server 127.0.0.1:3001;
     server 127.0.0.1:3002;
     server 127.0.0.1:3003;
   }

   server {
    upload_resumable on;
    client_max_body_size 100m;
    listen 3000;
    
    root /var/www/sms/public;
    access_log  /var/www/sms/log/nginx.access.log;

    if (-f $document_root/system/maintenance.html) {
      rewrite  ^(.*)$  /system/maintenance.html last;
      break;
    }
   
   #upload video
   location /upload_video {
          # Pass altered request body to this location
          upload_pass   @rails;
          upload_store /tmp 1;
        
          upload_store_access user:r;

          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 "^submit$|^description$";
          upload_cleanup 400 404 499 500-505;
    }

     # Upload image
     location /upload_image {
          # Pass altered request body to this location
          upload_pass   @rails;
          upload_store /tmp 1;
        
          upload_store_access user:r;

          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 "^submit$|^description$";
          upload_cleanup 400 404 499 500-505;
    }

    # Pass altered request body to a backend
    location @rails {
        proxy_pass   http://mongrel;
    }

    location / {
      proxy_set_header  X-Real-IP  $remote_addr;

      # needed for HTTPS
      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_max_temp_file_size 0;
      
      if (-f $request_filename) { 
        break; 
      }

      if (-f $request_filename/index.html) {
        rewrite (.*) $1/index.html break;
      }
      
      if (-f $request_filename.html) {
        rewrite (.*) $1.html break;
      }

      if (!-f $request_filename) {
        proxy_pass http://mongrel;
        break;
      }
    }

    error_page   500 502 503 504  /500.html;
    location = /500.html {
      root   /var/www/sms/public;
    }
  }

}



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值