使用nginx搭建文件服务器,使用nginx快速搭建文件服务器

准备工作:

关闭防火墙 systemctl stop firewalld && systemctl disable firewalld

禁用selinux setenforce 0 ----临时关闭

sed -i "s/SELINUX=enforcing/SELINUX=Disabled/g" /etc/selinux/config

安装nginx:

yum install nginx -y

安装完成后,验证nginx页面可以访问

4755297c7d65229dd65a947e262d081a.png

设置nginx文件服务器:

首先需要查看nginx是通过哪个配置文件启动

nginx -h

8e46567db9a5ba7b3b6ee9e3941c3d30.png

修改nginx配置文件:

vim /etc/nginx/nginx.conf 添加内容如下:

root         /usr/share/nginx/html    #文件存放的位置

autoindex on;                               #开启索引功能

autoindex_exact_size off;  # 关闭计算文件确切大小(单位bytes),只显示大概大小(kb mb gb)

autoindex_localtime on;   # 显示本机时间而非 GMT 时间

03aaafe6976dceb4a96432d6625536a7.png

:wq 保存并退出

重启nginx

systemctl restart nginx

登陆ip:8080

210b545b25c609020a0d9ec01366ce56.png

显示这个说明已经安装成功了!!!

原文:https://www.cnblogs.com/king-LL/p/10155026.html