瀏覽量:47次
ngx_upload模塊是nginx中一個文件上傳模式了,下面我們來看看nginx安裝文件上傳ngx_upload模塊步驟,希望例子對各位有幫助.
安裝nginx,并加入nginx upload module和nginx cache purge module:
mkdir ~/download
cd ~/download
wget http://www.grid.net.ru/nginx/download/nginx_upload_module-2.0.12.tar.gz
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 http://nginx.org/download/nginx-1.2.3.tar.gz
tar zxf nginx-1.2.3.tar.gz
cd nginx-1.2.3
./configure --prefix=/usr/local/nginx --with-pcre --with-http_ssl_module --add-module=../nginx_upload_module-2.0.12 --add-module=../ngx_cache_purge
make && make install
嘗試啟動:
/usr/local/nginx/sbin/nginx
ps aux | grep nginx
假如我的網(wǎng)站是放在 /home/mysite/www 下的,而nginx配置文件就放在 /home/mysite/etc 下:
省略了很多內(nèi)容的配置文件,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 http://www_backend;
}
}
將nginx_upload.conf獨立開來,是因為其他網(wǎng)站也可以包含此上傳配置文件:
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 "^.*$";
而最后那個參數(shù):upload_pass_form_field,代表可以將表單的所有參數(shù)保持原樣傳遞到后端,需要區(qū)分文件保存類型時很有用。
上一篇: 百度win10直通車檢測系統(tǒng)語言須為簡體中文的解決方法,百度win10直通車檢測系統(tǒng)怎么關(guān)閉
下一篇: win下無法ping通VM虛擬機(jī)CentOS系統(tǒng)的解決方法,ping不通vmware虛擬機(jī)
[聲明]本網(wǎng)轉(zhuǎn)載網(wǎng)絡(luò)媒體稿件是為了傳播更多的信息,此類稿件不代表本網(wǎng)觀點,本網(wǎng)不承擔(dān)此類稿件侵權(quán)行為的連帶責(zé)任。故此,如果您發(fā)現(xiàn)本網(wǎng)站的內(nèi)容侵犯了您的版權(quán),請您的相關(guān)內(nèi)容發(fā)至此郵箱【779898168@qq.com】,我們在確認(rèn)后,會立即刪除,保證您的版權(quán)。
官網(wǎng)優(yōu)化
整站優(yōu)化
渠道代理
400-655-5776