1.安装nginx: [root@test data]#yum install nginx -y
2.编辑配置文件: [root@test data]#vim /etc/nginx/nginx.conf 添加如下: autoindex on; ##显示目录 autoindex_exact_size on; ##显示文件大小 autoindex_localtime on; ##显示文件时间 server { listen 80 default_server; # listen [::]:80 default_server; server_name _; # root /usr/share/nginx/html; root /data; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { }
3.重启服务: [root@test data]#systemctl restart nginx
4.访问测试: