# Apacheのインストール
yum install httpd -y
# Apacheの起動
service httpd start
# Apacheの自動起動の設定
chkconfig httpd on
# 自動起動設定の確認
chkconfig httpd --list
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# httpd.confのオリジナルをバックアップ
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.origin
# NameVirutalHostの有効化
vi /etc/httpd/conf/httpd.conf
< #NameVirtualHost *:80
> NameVirtualHost *:80
# 80番ポートをListenしていることの確認
Listen 80
# 設置するバーチャルホストのconfファイルをIncludeするように追記
Include conf.userdefined/*.conf
# Documentを配置するディレクトリを準備
mkdir -p /var/www/example_dir
chown -R ユーザ名:ユーザ名 /var/www/example_dir
# バーチャルホストのconfファイルを作成
vi /etc/httpd/conf.userdefined/example_dir.conf
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example_dir"
DirectoryIndex index.html index.php
ErrorLog /var/log/httpd/example_dir_error_log
CustomLog /var/log/httpd/example_dir_access_log combined
AddDefaultCharset UTF-8
<Directory "/var/www/example_dir">
AllowOverride All
</Directory>
</VirtualHost>
# 設定に問題がないかを確認
service httpd configtest
# Apacheを再起動して設定を反映
service httpd restart
これを設定する事で、Apacheのバージョン情報などがレスポンスのフッター情報に表示されないようにできる。
# ServerSignatureの設定をoffにする
vi /etc/httpd/conf/httpd.conf
> ServerSignature Off
これを設定する事で、レスポンスヘッダにApacheバージョン情報などが表示されないようにできる。
# ServerTokensをProductOnlyに設定
vi /etc/httpd/conf/httpd.conf
> ServerTokens Prod || ServerTokens ProductOnly
# 設定に問題がないかを確認
service httpd configtest
# Apacheを再起動して設定を反映
service httpd restart