禁用CentOS下Apache的測試頁面
阿新 • • 發佈:2018-11-22
禁用CentOS下Apache的測試頁面
在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