作者:手机用户2602933613 | 来源:互联网 | 2014-05-28 09:40
今天给朋友的vps搞目录浏览,用来下载资料的,本来挺简单的的东西搞的挺郁闷的。现在线上的东西基本是搞nginx和lighttpd,apache忘的差不多了,搞个简单的目录浏览都要百度,我靠。。。现在直接写成脚本了。sed-i/Includeconf/extra/httpd-vhosts.conf/s/^#
今天给朋友的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 <
ServerAdmin rfyiamcool@51cto.com
DocumentRoot /var/www/html
ServerName www.123.com
ServerAlias shop.123.com
ErrorLog "logs/123.log" // 日志文件
CustomLog "logs/123.log" common // 日志文件
Options +Indexes FollowSymLinks
AllowOverride ALL
Order allow,deny
Allow from all
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/;
}