Apacheのバーチャルドメインの設定

Apacheのバーチャルドメインの設定

httpd.confの末尾に下記の設定を追加する。
NameVirtualHost 49.212.xxx.xxx:80

#49.212.xxx.xxxでアクセスされた場合に/var/www/html/の内容を表示する
<VirtualHost 49.212.xxx.xxx:80>
DocumentRoot /var/www/html/
ServerName 49.212.xxx.xxx
ErrorLog logs/html_Error_log
TransferLog logs/html_access_log
</VirtualHost>

#49.212.xxx.xxxでアクセスされた場合に/var/www/html/site1/の内容を表示する
<VirtualHost 49.212.xxx.xxx:80>
DocumentRoot /var/www/html/site1/
ServerName www.site1.com
ErrorLog logs/site1_Error_log
TransferLog logs/site1_access_log
</VirtualHost>

#49.212.xxx.xxxでアクセスされた場合に/var/www/html/site2/の内容を表示する
<VirtualHost 49.212.xxx.xxx:80>
DocumentRoot /var/www/html/site2/
ServerName www.site2.com
ErrorLog logs/site2_Error_log
TransferLog logs/site2_access_log
</VirtualHost>
49.212.xxx.xxxでアクセスされた場合に何も表示させたくない場合は

<VirtualHost 49.212.xxx.xxx:80>
DocumentRoot /var/www/html/
ServerName 49.212.xxx.xxx
ErrorLog logs/html_Error_log
TransferLog logs/html_access_log
</VirtualHost>

の替わりに
/var/www/dummy/
に空のフォルダを作成し、下記のように指定する。

<VirtualHost 49.212.xxx.xxx:80>
DocumentRoot /var/www/dummy/
ServerName 49.212.xxx.xxx
ErrorLog logs/dummy_Error_log
TransferLog logs/dummy_access_log
</VirtualHost>

 


コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です