nginx文件服务器搭建

一.安装 (CentOS 7)

yum install nginx -y

如果报错:

[u3@L3 /]$ sudo yum install nginx -y

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

 * base: mirrors.cn99.com

 * extras: mirrors.cn99.com

 * updates: mirrors.aliyun.com

No package nginx available.

Error: Nothing to do

先安装epel

yum install epel-release

 

二.启动

1、service nginx start

2、访问

 

三.文件目录配置

1vi /etc/nginx/nginx.conf

root配置:
        #root         /usr/share/nginx/html;

        root          /opt/package/;

Location / {}配置:

        location /package {

            autoindex on;

            autoindex_exact_size on;  # 显示文件大小

            autoindex_localtime on;  # 显示文件更新时间

            charset utf-8,gbk;

            add_header Content-Disposition attachment;  # 点击文件时下载

        }

2、nginx -s reload

(重新加载配置)

四.访问

/opt/package/package目录创建test.txt;

在浏览器中查看:

 

 

 

 

posted on 2019-07-04 18:10  喷气机  阅读(266)  评论(0编辑  收藏  举报

导航