2014-04-14 08:50:02
来 源
kejihao
Nginx
本文介绍Apache和Nginx服务器设置是否允许浏览目录,希望对于初学Nginx服务器相关的朋友有帮助,更多Nginx安装、配置、报错处理等资源请本站内搜索。。
今天给朋友的vps搞目录浏览,用来下载资料的,本来挺简单的的东西搞的挺郁闷的。现在线上的东西基本是搞nginx和lighttpd,apache忘的差不多了,搞个简单的目录浏览都要百度,我靠。。。现在直接写成脚本了。

sed -i '/Include conf/extra/httpd-vhosts.conf/s/^#//' /etc/httpd/conf/httpd.conf  

cat >>apache/conf/extra/httpd-vhosts.conf <<EOF 

<VirtualHost *:80> 

ServerAdmin [email protected]  

DocumentRoot /var/www/html   

ServerName www.123.com  

ServerAlias shop.123.com  

ErrorLog "logs/123.log" // 日志文件  

CustomLog "logs/123.log" common // 日志文件  

<Directory "/var/www/html">   

Options +Indexes FollowSymLinks  

AllowOverride ALL  

Order allow,deny  

Allow from all  

</Directory> 

 </VirtualHost>

EOF 

sed -i 's/^/#/' /etc/httpd/conf.d/welcome.conf 

nginx默认是不允许列出整个目录的。如需此功能,

        打开nginx.conf文件,在location server 或 http段中加入

        autoindex on;

        另外两个参数最好也加上去:

 

autoindex_exact_size off;

默认为on,显示出文件的确切大小,单位是bytes。

改为off后,显示出文件的大概大小,单位是kB或者MB或者GB

        autoindex_localtime on;

      默认为off,显示的文件时间为GMT时间。

      改为on后,显示的文件时间为文件的服务器时间

 

server{  

listen 80;  

servername www.A.com;  

autoindex on;  

autoindex_exact_size off;  

autoindex_localtime on;  

root /home/www/;  

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。