nginx 编译安装支持 upload progress module, upload module
下载地址:
wiki.nginx.org/HttpUploadModule
wiki.nginx.org/HttpUploadProgressModule
下载后解压至:/usr/src/文件夹下,其实这个随便放。
nginx.org
下方是rpm安装文件,自行下载.gz源码文件编译。
编译安装nginx 需要事先安装 yum install pcre-devel openssl-devel 等库
http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-1.2.7-1.el6.ngx.x86_64.rpm
以下参数 为安装文件产生的 configure 问题不大 适合CENTOS
rpm -ivh nginx-1.2.7-1.el6.ngx.x86_64.rpm
./configure --add-module=/usr/src/nginx-upload-module-2.2 --add-module=/usr/src/nginx-upload-progress-module --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' make make install
查看configure
nginx -V
安装完成后如果没有生成用户则自己新建
adduser -d /var/cache/nginx -s /sbin/nologin nginx
配置文件
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; upload_progress jsinguploads 1m; include /etc/nginx/conf.d/*.conf; }
server { listen 80; server_name _; client_max_body_size 500m; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /home/wwwroot/docs; index index.php; } location /upload_client { # Pass altered request body to this location upload_pass /uploadhandler; # Store files to this directory # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
# 请自行建好这些文件夹,系统不会自动建。 upload_store /home/wwwroot/docs/up_tmp 1; # Allow uploaded files to be read only by user upload_store_access user:r; # Set specified fields in request body 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"; # Inform backend about hash and size of a file 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_limit_rate 50k; upload_cleanup 400 404 499 500-505; track_uploads jsinguploads 30s; } location /uploadhandler { rewrite ^(.*)$ /index.php last; } location ^~ /progress { # report uploads tracked in the 'proxied' zone upload_progress_json_output; report_uploads jsinguploads; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /home/wwwroot/docs; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
posted on 2015-04-15 13:51 jsingsunck 阅读(1492) 评论(0) 编辑 收藏 举报