Apache禁用测试页(默认页)

来源:互联网 发布:pp助手for mac 编辑:程序博客网 时间:2024/05/16 00:37

在CentOS中安装apache并启动后,默认CentOS会为Apache添加一个测试页面,安装完毕并且对Apache的保持默认配置,之后在浏览器中输入你的站点的域名或ip地址,浏览器会打开如下界面

在此输入图片描述

该界面是用来测试Apache服务器是否工作正常。

禁用该测试页面的方法如下:

1.打开终端,登陆到CentOS上

2.在终端中输入以下命令

cd /etc/httpd/conf.d

3.继续输入命令,显示当前目录下的文件

ls

4.找到名为welcome.conf的文件,并用vim打开

vim welcome.conf

welcome.conf的内容如下

# # This configuration file enables the default "Welcome"# page if there is no default index page present for# the root URL.  To disable the Welcome page, comment# out all the lines below.#<LocationMatch "^/+$">    Options -Indexes    ErrorDocument 403 /error/noindex.html</LocationMatch>

文件中的说明性内容说明了该文件的主要作用,以及关闭该作用的方法。其实该文件也是一个普通的配置文件,并被包含进了Apache服务器httpd.conf主文件中,只要用"#"将welcome.conf的内容注释掉即可,如下:

# # This configuration file enables the default "Welcome"# page if there is no default index page present for# the root URL.  To disable the Welcome page, comment# out all the lines below.##<LocationMatch "^/+$">#    Options -Indexes#    ErrorDocument 403 /error/noindex.html#</LocationMatch>

5.重新启动Apache

service httpd restart

:查看noindex.html为存放路劲

cd /var/www/error/ls
0 0