I built a resource site for my own use a long time ago. I access domain names or addresses and directly list files and folders for easy viewing and downloading. The web environment I use is generally nginx, mainly Junge lnmp one-click package. I changed one of them yesterday, so I recorded it by the way so that I don’t have to search it on Baidu every time and it’s easier for me to read it. I hope it will be helpful to friends who have similar needs.
First, I put a picture of the effect I want. I feel that everyone’s expression is different, and the picture is the most realistic.
nginx_02
As shown in the picture, the access domain name lists files and folders. Let's take the LNMP environment as an example. First add the virtual host and add the domain name, and then modify the domain name configuration file. The file is located in /usr/ local/nginx/conf/vhost/, a .conf file named after the domain name. Please use an editor to add the code:

1
2
3
4
5
location / {   #Specify the directory path
autoindex on;   #Enable the directory browsing function, which is what we call listing files and folders
autoindex_exact_size on;< x2> #Enable detailed file size, unit b, can be turned off. If turned off, the unit is MB or GB
autoindex_localtime on;   #Turn on file modification date
}

It can be added at the location shown in the figure:
nginx
After adding it, we check the configuration file and restart Nginx:

1
2
/usr/local/nginx/sbin/nginx –t
service nginx reload

If there is no problem, accessing the domain name will display the list of incoming files and folders.
Another problem is that a few days ago I saw someone saying that Chinese characters would display garbled characters. It should be a problem with UTF8 encoding. However, I have tried using the LNMP environment on a foreign VPS several times and it was OK without any problems.

postid
11383

Leave a Reply