阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Apache控制是否显示站点目录

122次阅读
没有评论

共计 1783 个字符,预计需要花费 5 分钟才能阅读完成。

加载 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 +IndexesOptions 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

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计1783字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中