基于nginx搭建的网站共享镜像站
2020-05-09 本文已影响0人
南南宫问天
使用ngx_http_autoindex_module
ngx_http_autoindex_module
处理以斜杠字符(' /')结尾的请求,并生成目录列表
启用目录索引功能
[root@web02 ~]# cat /etc/nginx/conf.d/www.conf
server{
listen 80;
server_name www.czq.com; ##定义访问域名
location / {
root /html/www; ##定义站点目录
autoindex on; ---开启nginx站点目录索引功能
}
}
创建站点目录
[root@web02 ~]# mkdir /html/www/ -p
创建相关目录和文件
因为现在是测试环境,我们可以简单的创建一些文件来模拟企业中的私有镜像站
[root@web02 www]# mkdir {Centos,Ubuntu,Opensuse} ##创建种操作系统的镜像目录
[root@web02 www]# touch {Centos,Ubuntu,Opensuse}/{1..10}.txt ##给镜像目录放一些文件
[root@web02 www]# ls Centos/
10.txt 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt
[root@web02 www]# ls Ubuntu/
10.txt 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt
[root@web02 www]# ls Opensuse/
10.txt 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt
重启nginx
[root@web02 www]# systemctl restart nginx
打开浏览器输入域名访问(提前配置好hosts,否则用地址访问)




[图片上传中...(image.png-3572d1-1589020236182-0)]