サブドメイン
www.example.comで運用中のサーバに
hoge.example.comのようにサブドメインを追加する場合の覚書
※hoge.example.comのドキュメントルートは任意の場所に指定可能
サブドメインを使用するにはまず、DNSレコードを変更する必要がある。
レンタルサーバで申請できる場合は以下のように申請。
例)
サブドメイン hogeを作る場合
ホスト: hoge A サーバのIPアドレス
DNSレコードが変更されれば後は
apacheのhttp.confを以下のように修正
# vi /etc/httpd/conf/httpd.conf
NameVirtualHost *:80 #を取る
#以下追加
<virtualhost *:80>
ServerName www.example.com
DocumentRoot /var/www/html 元からのデータのディレクトリ
</virtualhost>
<virtualhost *:80>
ServerName hoge.example.com
DocumentRoot /home/hoge/html hoge用のディレクトリ
<directory “/home/hoge/htm”>
AllowOverride All
Allow from All
</directory>
</virtualhost>
【注意!!】
新たなサブドメインにも.htaccessを適用させる場合は
<directory>の設定をしないといけない!
トラックバック URL :
コメント (0)


