apache中显示目录列表
在http.conf中加入如下代码(如有虚拟主机配置,加在虚拟主机配置段内),并把主目录内的index.pho,index.html,index.htm文件删除
复制代码 代码如下:
Alias /download "/download"
<Directory "/download">
Options Indexes
Order allow,deny
IndexOptions Charset=UTF-8
Allow from all
</Directory>
<Directory "/download">
Options Indexes
Order allow,deny
IndexOptions Charset=UTF-8
Allow from all
</Directory>
其中“/download”是要显示文件列表的目录,参数"Options Indexes"表示启用目录浏览,"IndexOptions Charset=UTF-8"设置字符集,以消除中文乱码。
注意:
但是在centos中我们这么设置也有可能看不到目录结构,这是因为有一个/etc/httpd/conf.d/welcome.conf.


所以我们还需要修改welcome.conf文件








图中注释的说明已经这清楚了:
这是显示welcome页面的配置文件,当根路径下没有index文件时,默认显示这个欢迎页面,如果不想显示welcome页,注释点下面的这些行
切记:
对 httpd.conf 的每次修改,最好或者说必须重启Apache,linux下Apache启动,停止,重启命令
基本的操作方法:
apahce启动命令:
推荐/usr/local/apache2/bin/apachectl start apaceh启动apache停止命令
/usr/local/apache2/bin/apachectl stop 停止apache重新启动命令:
/usr/local/apache2/bin/apachectl restart 重启要在重启 Apache 服务器时不中断当前的连接,则应运行:
/usr/local/sbin/apachectl graceful
如果apache安装成为linux的服务的话,可以用以下命令操作:
service httpd start 启动
service httpd restart 重新启动
service httpd stop 停止服务
问题:
这里重启虽然成功了,但是有一个提示


解决:还是http.conf文件


注意这里的说明:我只是开发使用,没有DNS name,所以设置成127.0.0.1这个回传地址


重启Apache


浏览器中输入:http://localhost或http://127.0.0.1(如果你的port端口不是80,那就还有:port 加上端口号)

