http方式访问目录文件
1,这里使用apache
[root@vm7 ftp]# rpm -qa httpd httpd-2.4.6-97.el7.centos.5.x86_64
2,编辑httpd配置文件
[root@vm7 ftp]# vi /etc/httpd/conf/httpd.conf
DocumentRoot "/mnt/ftp"httpd.conf"/mnt/ftp"> AuthType Basic AuthName "welcome to my server." AuthUserFile "/mnt/userpasswd" Require user user Options Indexes FollowSymLinks ExecCGI Allow from all
DocumentRoot "/mnt/ftp" #设置访问目录 # Further relax access to the default document root:"/mnt/ftp"> #设置访问目录 AuthType Basic #设置认证类型为Basic AuthName "welcome to my server." #设置认证提示 AuthUserFile "/mnt/userpasswd" #设置认证文件路径 Require user user #设置允许访问的用户user Options Indexes FollowSymLinks ExecCGI #开启子目录访问权限 Allow from all
IndexOptions IconHeight=20 IconWidth=20 FancyIndexing HTMLTable VersionSort FoldersFirst Charset=UTF-8 NameWidth=* XHTML
#IconHeight IconWidth 配置图标高度与宽度, NameWidth=* #自适应列表宽度,比如文件名过长会自动拉神列宽度,否则会造成乱码
3,编辑 [root@vm7 ~]# vi /etc/httpd/conf.d/welcome.conf
"^/+$"> # Options -Indexes #去掉-,让它支持访问文件 Options Indexes ErrorDocument 403 /.noindex.html
4,设置密码认证文件
[root@vm7 ftp]# htpasswd -cb /mnt/userpasswd admin 123456 #设置密码认证文件,并创建用户admin,密码123456 [root@vm7 ftp]# htpasswd -b /mnt/userpasswd user 123456 #添加添加第二个user用户
5,浏览器访问
6,访问效果