centos7 apache 2.4 开启 文件夹显示文件

0x00

这个小技巧还是非常的实用的,我找了好些帖子实际上都是说的是 apache 2.2,所以一直没成功,甚至有些怀疑自己了,这么简单的东西就是不起作用。最后发现的问题所在,下面记录下来

yum install httpd
vim /etc/httpd/conf/httpd.conf

修改内容有

DocumentRoot "/download"
# 要共享的目录

<Directory "/download">
    # 目录的设置访问设置就两条
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

在这个例子中,所有的请求是允许的。我是走了好些弯路,有好些配置都是 apache 2.2 中的,所以要吧里面的一些东西改成apache 2.4的才行

2.2配置:

Order allow,deny
Allow from all
2.4配置:

Require all granted

最后重启 httpd

systemctl restart httpd

再去登录 127.0.0.1 或 ip 地址,就能看到文件列表了

上一篇
下一篇