码迷,mamicode.com
首页 > 其他好文 > 详细

利用nginx下载服务器本地的文件

时间:2017-10-20 15:58:01      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:nginx 下载服务器 文件

#安装nginx

yum -y install nginx

#启动nginx服务

systemctl start nginx

#查看nginx服务进程

ps -ef|grep nginx


#yum安装nginx的默认站点目录

/usr/share/nginx/html

 

#全磁盘查找nginx配置文件

find / -name nginx.conf


#备份配置文件

cp nginx.conf nginx.conf.ori.20171019


#修改nginx配置文件(/etc/nginx/nginx.conf,这是yum安装nginx的默认配置文件所在的路径

[root@iZ2ze4260oe720hZnginx]# cat nginx.conf
# For moreinformation on configuration, see:
#   * Official English Documentation:http://nginx.org/en/docs/
#   * Official Russian Documentation:http://nginx.org/ru/docs/
 
user nginx;
worker_processesauto;
error_log/var/log/nginx/error.log;
pid/run/nginx.pid;
 
# Load dynamicmodules. See /usr/share/nginx/README.dynamic.
include/usr/share/nginx/modules/*.conf;
 
events {
    worker_connections 1024;
}
 
http {
    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;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
 
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
 
    # Load modular configuration files from the/etc/nginx/conf.d directory.
    # Seehttp://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
 
    server {
        listen       80 default_server;
        root         /usr/share/nginx/html;
 
        # Loadconfiguration files for the default server block.
        include/etc/nginx/default.d/*.conf;
 
        location /{
        index  index.html index.htm;
        autoindexon;       #开启nginx目录浏览功能
       autoindex_exact_size off;   #文件大小从KB开始显示
                        #默认为on,显示出文件的确切大小,单位是bytes。
                         #改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
       autoindex_localtime on;     #显示文件修改时间为服务器本地时间
        charsetutf-8,gbk;          #显示中文
     #  limit_conn one 8;        #并发数
        limit_rate100k;         #单个线程最大下载速度,单位KB/s        }
 
        error_page 404 /404.html;
            location = /40x.html {
        }
 
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
    }
}


#重启nginx服务

systemctl restart nginx


#在浏览器查看下载界面

技术分享


参考文档:

https://my.oschina.net/Jacedy/blog/618131——利用Nginx访问、下载本机目录文件

http://2853725.blog.51cto.com/2843725/1381509——nginx报错zero sizeshared memory zone "one"

本文出自 “dark-matter” 博客,请务必保留此出处http://gagarin.blog.51cto.com/1056957/1974586

利用nginx下载服务器本地的文件

标签:nginx 下载服务器 文件

原文地址:http://gagarin.blog.51cto.com/1056957/1974586

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!