サブドメイン Apach2 Ubuntu 10.04 の設定。仮想ホストは現在使用されていません

サブドメイン Apach2 Ubuntu 10.04 の設定。仮想ホストは現在使用されていません

現在、単一の Web サイトを実行するためだけに設定されている Ubuntu 10.04 サーバーがあります。この Web サイトの特定のセクションを指すようにサブドメインを設定したいと考えています。たとえば、test.example.com が example.com/testing を指すようにしたいのですが、これを実現する最善の方法は何でしょうか?

答え1

新しい vhost を作成します。

touch /etc/apache2/sites-available/test.example.com

コンテンツを追加します:

<VirtualHost *:80>
    ServerName test.example.com
    DocumentRoot /var/www/test
    # ..any other config needed
    <Directory /var/www/test>
        Order Allow,Deny
        Allow from all
    </Directory>
</VirtualHost>

有効にする:

a2ensite test.example.com

Apacheを再起動します。

service apache2 restart

新しいtest.example.com名前の名前解決がサーバーを正しく指していることを確認してください。

関連情報