首页 > 其他 > 详细

nginx文件服务器搭建

时间:2019-07-04 19:13:00      阅读:97      评论:0      收藏:0      [点我收藏+]

一.安装 (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;

在浏览器中查看:

 技术分享图片

 

 

 

nginx文件服务器搭建

原文:https://www.cnblogs.com/penqiji/p/11134094.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!