[root@centos ~]# mkdir /var/www/html/virtual ← バーチャルホスト用ドキュメントルートディレクトリ作成
[root@centos ~]# vi /etc/httpd/conf/httpd.conf ← Apache設定ファイル編集
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work. See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
#ServerName www.centossrv.com:80 ← 行頭に#を追加してコメントアウト
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80 ← コメント解除(バーチャルホスト有効化)
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#
[root@centos ~]# vi /etc/httpd/conf.d/virtualhost-00.conf ← 未定義ホスト用バーチャルホスト設定ファイル作成
※バーチャルホスト未定義ホスト名でアクセス時にアクセスを拒否する
<VirtualHost *:80>
ServerName any
<Location />
Order deny,allow
Deny from all
</Location>
</VirtualHost>
[root@centos ~]# vi /etc/httpd/conf.d/virtualhost-www.centossrv.com.conf ← メインホスト用バーチャルホスト設定ファイル作成
<VirtualHost *:80>
ServerName www.centossrv.com
DocumentRoot /var/www/html
</VirtualHost>
[root@centos ~]# vi /etc/httpd/conf.d/virtualhost-virtual.com.conf ← 追加ホスト用バーチャルホスト設定ファイル作成
<VirtualHost *:80>
ServerName virtual.com
DocumentRoot /var/www/html/virtual
ErrorLog logs/virtual-error_log
CustomLog logs/virtual-access_log combined env=!no_log
</VirtualHost>
|
|