你好,游客 登录 注册 搜索
背景:
阅读新闻

Apache控制是否显示站点目录

[日期:2016-11-24] 来源:Linux社区  作者:ggh19 [字体:大 中 小]

加载 mod_autoindex 模块

Apache 2.4版本,如果要控制站点目录是否显示,需要 mod_autoindex 模块。如果没有该模块,显示站点目录的指令无效。

加载该模块

LoadModule autoindex_module modules/mod_autoindex.so

方法一

解决过程:首先查看apache官网文档,不能快速找到需要的部分。用搜索引擎查找“apache显示站点目录”,找到相关资料,雷同。按照资料说明配置无效。
开始尝试在虚拟主机和非虚拟主机尝试资料中的配置,仍然无效。再回到官网文档查找关键词“Options Indexes”,看到“mod_autoindex can generate a listing of the directory contents”,
然后全文检索httpd.conf,意识到是因为相关模块没有加载。

虚拟主机显示站点目录

apache 2.4版本默认不显示站点目录,虚拟主机配置如下:

<VirtualHost *:80>
    ServerAdmin chuganghong@qq.com
    DocumentRoot "E:\wamp64\www\my-site\test-php"
    ServerName test-php.com
    ErrorLog "logs/test-php.com-error.log"
    CustomLog "logs/test-php.com-access.log" common
</VirtualHost>

加入显示站点目录的指令 Options +Indexes,完整代码如下:

<VirtualHost *:80>
    <Directory "E:\wamp64\www\my-site\test-php">
        Options +Indexes    # 显示站点目录
    </Directory>
    ServerAdmin chuganghong@qq.com
    DocumentRoot "E:\wamp64\www\my-site\test-php"

    ServerName test-php.com
    ErrorLog "logs/test-php.com-error.log"
    CustomLog "logs/test-php.com-access.log" common
</VirtualHost>

Options +Indexes 或 Options Indexes 或没有这条指令,显示站点目录。
Options -Indexes,禁止显示站点目录。

参考资料

mod_autoindex can generate a listing of the directory contents

Ubuntu Server 14.04 安装Web服务器(Linux+Apache+MySQL+PHP)  http://www.linuxidc.com/Linux/2015-06/119061.htm

Linux下安装配置PHP环境(Apache2)  http://www.linuxidc.com/Linux/2015-05/118062.htm

Linux下 Apache服务器配置  http://www.linuxidc.com/Linux/2016-06/132025.htm

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm

Linux下Apache服务器配置 http://www.linuxidc.com/Linux/2016-10/136517.htm

Linux下Apache虚拟主机的配置  http://www.linuxidc.com/Linux/2016-04/130381.htm

Ubuntu下Apache的安装与配置 http://www.linuxidc.com/Linux/2016-11/136841.htm

Apache 的详细介绍:请点这里
Apache 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-11/137485.htm

linux
相关资讯       Apache站点目录 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款