一、效果

二、解决方案
修改网站配置文件,添加如下代码:
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
修改后的网站配置文件如下:
server {listen       80;server_name  test.haveyb.com;charset utf-8;error_log    /logs/nginx/error/test.haveyb.com.log error;access_log   /logs/nginx/access/test.haveyb.com.log main;root   /data/test;location /favicon.ico {log_not_found off;access_log off;}location / {#显示目录autoindex on;autoindex_exact_size off;autoindex_localtime on;}location ~ \.php$ {fastcgi_pass   unix:/dev/shm/php-cgi.sock;fastcgi_index  index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include        fastcgi_params;}location ~ /\.ht {deny  all;}
}
三、需要注意的
1、修改网站配置文件后,记得重启nginx
systemctl restart nginx2、如果目录下有index.html,将不再显示目录,而变成直接显示index.html 内容,可以将 index.html 改为其他名字,比如index2.html