apache VirtualHost local

てっとり早くローカルでバーチャルホストを確認します。

まず/usr/local/apache/conf/httpd.conf

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ServerName 127.0.0.1
NameVirtualHost *

<VirtualHost *>
ServerName test2.anan
DocumentRoot /usr/local/apache/htdocs/testsite
ErrorLog logs/error_log
TransferLog logs/access_log
</VirtualHost>

<VirtualHost *>
ServerName test_site.anan
DocumentRoot /usr/local/apache/htdocs/testsite2
ErrorLog logs/error_log2
TransferLog logs/access_log2
</VirtualHost>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

↑こんな感じで↑


そして、DocumentRootで指定したパス以下にindex.htmlでも作成して下さい。

続いて、/etc/hosts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127.0.0.1 localhost.localdomain localhost test2.anan test_site.anan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
と、言った感じでタブ区切りか、半角スペース区切りでドメイン名を書き込みます。

では、ブラウザで確認してみて下さい。

良かったですね^^