さくらVPSでマルチドメイン設定
マルチドメインの設定をしたので、メモです。
さくらVPSで、複数のドメインを使いたいと思いながら、
ずっとそのままになっていたので、やってみることにしました。
Virtual Hostって呼ぶらしいです。
OS:Mac OS X
(1)ディレクトリを作成する
mkdir -p /var/www/html/example1.com/public_html
mkdir -p /var/www/html/example2.com/public_html
(2)権限変更
chown -R username:username /var/www/html/example1.com
chown -R username:username /var/www/html/example2.com
(3)confファイルを作成する
vim /etc/httpd/conf.d/vhost.conf
(4)vhost.confにこの内容を作成する
<VirtualHost *:80> ServerName example1.com ServerAlias www.example1.com DocumentRoot "/var/www/example1.com/public_html" DirectoryIndex index.html index.php ErrorLog /var/log/httpd/example1.com_error_log CustomLog /var/log/httpd/example1.com_access_log combined AddDefaultCharset UTF-8 <Directory "/var/www/html/example1.com/public_html"> AllowOverride All </Directory> </VirtualHost> <VirtualHost *:80> ServerName example2.com ServerAlias www.example2.com DocumentRoot "/var/www/example2.com/public_html" DirectoryIndex index.html index.php ErrorLog /var/log/httpd/example2.com_error_log CustomLog /var/log/httpd/example2.com_access_log combined AddDefaultCharset UTF-8 <Directory "/var/www/html/example2.com/public_html"> AllowOverride All </Directory> </VirtualHost>
*ServerNameが、ドメイン名で割り振っている場所です。
*ServerAliasで、www付きでアクセスしても、同様の場所を表示させるようになっています。
(5)きちんと表記できているか確認
service httpd configtest
(6)リロードする
service httpd reload
以上です。それぞれのディレクトリにindex.htmlを置いて確認してみて下さいー!