1.媒介 当我们但愿分享本身的文件时,有多种方法,局域网可以回收共享,rtx传输,qq传输,发送到邮箱,直接u盘拷贝等等。但最简朴的就是开启当地处事器,其他电脑通过网页的方法直接下载,这里先容利用nginx作为处事器举办下载
2.步调
1.下载nginx http://nginx.org/en/download.html 今朝不变版本为1.80 解压到一个目次
2.修改设置文件 nginx.conf
#user nobody;
worker_processes ;
#error_log logs/ "hljs-keyword">error.log;
#error_log logs/ "hljs-keyword">error.log notice;
#error_log logs/ "hljs-keyword">error.log info;
#pid logs/nginx.pid;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
"hljs-preprocessor">#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
"hljs-preprocessor"># '$status $body_bytes_sent "$http_referer" '
"hljs-preprocessor"># '"$http_user_agent" "$http_x_forwarded_for"';
"hljs-preprocessor">#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout ;
#gzip on;
server {
listen ;
server_name localhost;
#charset koi8-r;
"hljs-preprocessor">#access_log logs/host.access.log main;
location / {
#root html;
"hljs-preprocessor">#index index.html index.htm;
"hljs-keyword">if ($request_filename ~* ^.*?.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
add_header Content-Disposition: "hljs-string">'attachment;';
}
}
"hljs-preprocessor">#error_page 404 /404.html;
"hljs-preprocessor"># redirect server "hljs-keyword">error pages to the static page /50x.html
#
error_page /x.html;
location = /x.html {
root html;
}
}
}
3.在nginx目次下的html中成立目次test和test.rar文件
4.打开呼吁行切换到nginx目次
4.1测试剧本 nginx -t
4.2开启处事器 start nginx
4.3打开欣赏器 http://localhost:8080/test/test.rar应该弹出另存为对话框
4.4封锁处事器nginx -s quit
,新加坡电信服务器 马来西亚服务器