一、效果
?
二、解決方案
修改網站配置文件,添加如下代碼:
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 nginx
2、如果目錄下有index.html,將不再顯示目錄,而變成直接顯示index.html 內容,可以將 index.html 改為其他名字,比如index2.html
?