[root@fedora ~]# mkdir /var/www/html/virtual.com ← バーチャルホスト用ドキュメントルートディレクトリ作成
[root@fedora ~]# 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 fedorasrv.com:80 ← 行頭に#を追加してコメントアウト
NameVirtualHost *:80 ← コメント解除(バーチャルホスト有効化)
[root@fedora ~]# vi /etc/httpd/conf.d/virtualhost-00.conf ← 未定義ホスト用バーチャルホスト設定ファイル作成
※バーチャルホスト未定義ホスト名でアクセス時にアクセスを拒否する
<VirtualHost *:80>
ServerName any
<Location />
Order deny,allow
Deny from all
</Location>
</VirtualHost>
[root@fedora ~]# vi /etc/httpd/conf.d/virtualhost-fedorasrv.com.conf ← メインホスト用バーチャルホスト設定ファイル作成
<VirtualHost *:80>
ServerName fedorasrv.com
DocumentRoot /var/www/html
</VirtualHost>
[root@fedora ~]# 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>
|
|