nginx 는 다운로드 파일 서버 로 서

3404 단어 centos
1. 머리말
우리 가 자신의 파일 을 공유 하고 싶 을 때, 랜 은 공유, rtx 전송, qq 전송, 메 일 로 보 내기, 직접 u 디스크 복사 등 여러 가지 방식 을 사용 할 수 있 습 니 다.그러나 가장 간단 한 것 은 로 컬 서버 를 켜 고 다른 컴퓨터 는 웹 페이지 를 통 해 직접 다운로드 하 는 것 입 니 다. nginx 를 서버 로 다운로드 하 는 것 을 소개 합 니 다.
2. 절차
1. nginx 다운로드 http://nginx.org/en/download.html 현재 안정 버 전 은 1.80 으로 디 렉 터 리 에 압축 을 풀 었 습 니 다.
2. 프로필 수정
nginx.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 #user  nobody; 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 {          listen       8080;          server_name  localhost;            #charset koi8-r;            #access_log  logs/host.access.log  main;            location / {              #root   html;              #index  index.html index.htm;                if   ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){              add_header Content-Disposition:  'attachment;' ;              }          }          #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   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 종료

좋은 웹페이지 즐겨찾기