このブログを旧サイトから移管し、同一ホストで別々のドメインを運用することになったので、バーチャルホストの設定を行いました。
設定方法
http.conf
1 |
NameVirtualHost *:80 |
実際のバーチャルホストの設定ファイル
実際にはconf.d/~などに記述
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<VirtualHost *:80> ServerName ドメイン1 DocumentRoot "/var/www/html/ドメイン1のルートディレクトリ" DirectoryIndex index.html index.php ErrorLog /var/log/httpd/エラーログのパス CustomLog /var/log/httpd/アクセスログのパス AddDefaultCharset UTF-8 <Directory "/var/www/html/ドメイン1のルートディレクトリ"> AllowOverride All </Directory> </VirtualHost> <VirtualHost *:80> ServerName ドメイン2 DocumentRoot "/var/www/html/ドメイン2のルートディレクトリ" DirectoryIndex index.html index.php ErrorLog /var/log/httpd/エラーログのパス CustomLog /var/log/httpd/アクセスログのパス AddDefaultCharset UTF-8 <Directory "/var/www/html/ドメイン2のディレクトリ"> AllowOverride All </Directory> </VirtualHost> |
注意点としてはhttp.confにもともとあるServernameをコメントアウトしないと正確にバーチャルホストのドメインが反映されないようです。結構悩みましたね・・・