Linux(CentOS 6) - 「Apache HTTP Server Test Page powered by CentOS」ページを削除する方法

CentOS 6でApache(httpdパッケージ)をインストールし、Apacheの設定を何も変更することなく、かつ、DocumentRoot配下にindex.htmlを設置しない状態でサイトトップページをブラウザでアクセスすると、403エラーが発生し、以下のようなページが表示される。

Apache HTTP Server Test Page powered by CentOS(CentOS 6 - Apacheパッケージのウェルカムページ)

《備考》
ApacheのDocumentRoot:/var/www/html ←初期設定
サイトトップページのURL:http://192.168.0.9
アクセス元PCのIPアドレス:192.168.0.2

アクセスログ(/var/log/httpd/access_log):
192.168.0.2 - - [11/May/2013:10:16:14 +0900] "GET / HTTP/1.1" 403 5039 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"

エラーログ(/var/log/httpd/error_log):
[Sat May 11 10:16:14 2013] [error] [client 192.168.0.2] Directory index forbidden by Options directive: /var/www/html/

この「Apache HTTP Server Test Page powered by CentOS」ページを削除したい場合、/etc/httpd/conf.d/直下にあるwelcome.confを修正する、または、welcome.confを削除すればよい。

以下は、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>

上記ファイル内の英文説明には、以下のようなことが書かれている。

この設定ファイルは、トップページを表示するためのインデックスページが存在しない場合、デフォルトの「ウェルカム」ページを表示します。ウェルカムページを非表示にするには、以下の行を全てコメントアウトしてください。

というわけで、該当行の冒頭に#(シャープ記号)を追記し、コメントアウト(comment out)する。

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を再起動すると、「Apache HTTP Server Test Page powered by CentOS」ページ(ウェルカムページ)が表示されない設定に変わる。
[root@test conf.d]# /etc/rc.d/init.d/httpd restart

前へ

Linux(CentOS 6) - yum installコマンドでpostgresqlパッケージをインストールする

次へ

Linux(CentOS 6) - Apacheで「Index of /」ページが表示されないようにする方法